赞
踩
compile group: 'antlr', name: 'antlr', version: '2.7.7'
compile group: 'aopalliance', name: 'aopalliance', version: '1.0'
compile group: 'org.aspectj', name: 'aspectjrt', version: '1.8.5'
compile group: 'com.mchange', name: 'c3p0', version: '0.9.2.1'
compile group: 'com.fasterxml', name: 'classmate', version: '1.1.0'
compile group: 'classworlds', name: 'classworlds', version: '1.1'
compile group: 'org.aspectj', name: 'aspectjweaver', version: '1.8.5'
compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.2'
compile group: 'commons-collections', name: 'commons-collections', version: '3.2.1'
compile group: 'commons-dbcp', name: 'commons-dbcp', version: '1.4'
compile group: 'commons-digester', name: 'commons-digester', version: '2.1'
compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.2'
compile group: 'commons-io', name: 'commons-io', version: '2.4'
compile group: 'commons-lang', name: 'commons-lang', version: '2.4'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
compile group: 'commons-logging', name: 'commons-logging', version: '1.1.3'
compile group: 'commons-pool', name: 'commons-pool', version: '1.6'
compile group: 'dom4j', name: 'dom4j', version: '1.6.1'
compile group: 'dwr', name: 'dwr', version: '1.1.1'
compile group: 'net.sf.ehcache', name: 'ehcache', version: '2.10.1'
compile group: 'net.sf.ezmorph', name: 'ezmorph', version: '1.0.6'
compile group: 'org.freemarker', name: 'freemarker', version: '2.3.23'
//hibernate
compile group: 'org.hibernate', name: 'hibernate-c3p0', version: '5.1.4.Final'
compile group: 'org.hibernate.common', name: 'hibernate-commons-annotations', version: '5.0.1.Final'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.1.4.Final'
compile group: 'org.hibernate', name: 'hibernate-ehcache', version: '5.1.4.Final'
compile group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.1.4.Final'
compile group: 'org.hibernate', name: 'hibernate-envers', version: '5.1.4.Final'
compile group: 'org.hibernate', name: 'hibernate-java8', version: '5.1.4.Final'
compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.0.Final'
compile group: 'org.hibernate', name: 'hibernate-jpamodelgen', version: '5.1.4.Final'
compile group: 'org.hibernate', name: 'hibernate-proxool', version: '5.1.4.Final'
compile group: 'org.infinispan', name: 'infinispan-commons', version: '8.2.5.Final'
compile group: 'org.infinispan', name: 'infinispan-core', version: '8.2.5.Final'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.6.0'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.6.1'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.6.1'
compile group: 'org.jboss', name: 'jandex', version: '2.0.3.Final'
compile group: 'org.javassist', name: 'javassist', version: '3.22.0-GA'
compile group: 'org.jboss.logging', name: 'jboss-logging', version: '3.3.0.Final'
compile group: 'org.jboss.marshalling', name: 'jboss-marshalling-osgi', version: '1.4.10.Final'
compile group: 'org.jboss.spec.javax.transaction', name: 'jboss-transaction-api_1.1_spec', version: '1.0.1.Final'
//kanyixia
compile group: 'net.sf.json-lib', name: 'json-lib', version: '2.3'
compile group: 'javax.servlet.jsp.jstl', name: 'jstl', version: '1.2'
compile group: 'com.vividsolutions', name: 'jts', version: '1.13'
compile group: 'log4j', name: 'log4j', version: '1.2.16'
compile group: 'org.slf4j', name: 'log4j-over-slf4j', version: '1.6.1'
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.7'
compile group: 'ch.qos.logback', name: 'logback-core', version: '1.0.7'
compile group: 'com.mchange', name: 'mchange-commons-java', version: '0.2.3.4'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.27'
compile group: 'proxool', name: 'proxool', version: '0.8.3'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.6.1'
testCompile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.6.1'
testCompile group: 'org.slf4j', name: 'slf4j-nop', version: '1.6.1'
//spring
compile group: 'org.springframework', name: 'spring-aop', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-aspects', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-beans', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-context', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-context-support', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-core', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-expression', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-instrument', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-jdbc', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-messaging', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-oxm', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-tx', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-web', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-webmvc', version: '4.3.6.RELEASE'
compile group: 'org.springframework', name: 'spring-webmvc-portlet', version: '4.3.6.RELEASE'
compile group: 'org.codehaus.woodstox', name: 'stax2-api', version: '3.1.4'
compile group: 'stax', name: 'stax-api', version: '1.0.1'
compile group: 'org.codehaus.woodstox', name: 'woodstox-core-asl', version: '4.4.1'
compile group: 'wsdl4j', name: 'wsdl4j', version: '1.6.3'
compile group: 'xalan', name: 'xalan', version: '2.7.0'
compile group: 'xerces', name: 'xercesImpl', version: '2.7.1'
compile group: 'xml-apis', name: 'xml-apis', version: '1.3.04'
compile group: 'xml-apis', name: 'xml-apis-ext', version: '1.3.04'
compile group: 'xmlbeans', name: 'xmlbeans', version: '2.3.0'
compile group: 'org.apache.xmlgraphics', name: 'xmlgraphics-commons', version: '1.4'
compile group: 'xmlpull', name: 'xmlpull', version: '1.1.3.1'
compile group: 'xml-resolver', name: 'xml-resolver', version: '1.2'
compile group: 'org.apache.ws.xmlschema', name: 'xmlschema-core', version: '2.1.0'
compile group: 'xpp3', name: 'xpp3_min', version: '1.1.4c'
|
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>TestApp</display-name>
<!-- log4j 监听 -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:resources/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!--Spring 拦截监听 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:META-INF/spring/applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 字符集 -->
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- spring mvc 拦截 -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:META-INF/spring/springmvc-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- 配置 HiddenHttpMethodFilter过滤器 -->
<!-- 由于浏览器form表单只支持GET与POST请求,而DELETE、PUT等method并不支持,Spring4.0添加了一 个过滤器,可以将这些请求转换为标准的http方法,
使得支持GET、POST、PUT与DELETE请求,该过滤器为HiddenHttpMethodFilter -->
<filter>
<filter-name>hiddenHttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hiddenHttpMethodFilter</filter-name>
<url-pattern>/</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
|
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd ">
<mvc:annotation-driven />
<!-- ①:对web包中的所有类进行扫描,以完成Bean创建和自动依赖注入的功能 -->
<context:component-scan base-package="com.srx" />
<!-- 这两个类用来启动基于Spring MVC的注解功能,将控制器与方法映射加入到容器中 -->
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<!-- 这个类用于Spring MVC视图解析 -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- 对前台传过来的json数据进行处理 -->
<bean
class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="order" value="1" />
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" />
</list>
</property>
</bean>
<!--这里是对静态资源的映射 -->
<mvc:resources mapping="/js/**" location="/resources/js/" />
<mvc:resources mapping="/css/**" location="/resources/css/" />
<mvc:resources mapping="/img/**" location="/resources/img/" />
</beans>
|
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.3.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-4.3.xsd">
<!-- 扫描包 -->
<context:component-scan base-package="com.srx"/>
<context:annotation-config/>
<!-- 引人其他文件 -->
<import resource="data-source-tx.xml"></import>
</beans>
|
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-4.3.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<!-- 获取hibernate.properties配置文件 -->
<context:property-placeholder location="classpath:resources/config.properties" />
<!-- dataSource 配置c3po数据源,mysql数据库 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<!-- these are C3P0 properties -->
<property name="acquireIncrement" value="${c3p0.acquireIncrement}" />
<property name="minPoolSize" value="${c3p0.minPoolSize}" />
<property name="maxPoolSize" value="${c3p0.maxPoolSize}" />
<property name="maxIdleTime" value="${c3p0.maxIdleTime}" />
</bean>
<!-- sessionFactory -->
<!-- spring与hibernate整合配置,扫描所有的dao -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.srx.bean" />
<property name="hibernateProperties">
<props>
<!-- 有待研究 -->
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.auto-import">false</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<!-- 配置Hibernate事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 事物注解配置 对数据源进行事务管理 -->
<!-- 这里有过整体改动 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="*" propagation="REQUIRED" rollback-for="Exception" />
</tx:attributes>
</tx:advice>
</beans>
|
package com.srx.bean;
import static javax.persistence.GenerationType.IDENTITY;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="db_user")
public class User implements Serializable {
/**
*/
private static final long serialVersionUID = 1L;
private Integer id; // id
private String name; // name
private String pwd; // pwd
private Integer age; // age
private Date creatTime; // creatTime
@Id
@GeneratedValue(strategy = IDENTITY)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public Date getCreatTime() {
return creatTime;
}
public void setCreatTime(Date creatTime) {
this.creatTime = creatTime;
}
public User() {
super();
// TODO Auto-generated constructor stub
}
public User(Integer id, String name, String pwd, Integer age, Date creatTime) {
super();
this.id = id;
this.name = name;
this.pwd = pwd;
this.age = age;
this.creatTime = creatTime;
}
@Override
public String toString() {
return "User [id=" + id + ", name=" + name + ", pwd=" + pwd + ", age=" + age + ", creatTime=" + creatTime + "]";
}
}
|
package com.srx.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import com.srx.bean.User;
@Controller
public class UserController {
@RequestMapping("")
public String Create(Model model) {
return "create";
}
@RequestMapping("/save")
public String Save(@ModelAttribute("form") User user, Model model) { // user:视图层传给控制层的表单对象;model:控制层返回给视图层的对象
model.addAttribute("user", user);
System.out.println("前台后台交往成功");
return "detail";
}
}
|
log4j.rootLogger = info,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH:mm:ss}][%C{1}:%L] - %m%n
#log4j.appender.file = org.apache.log4j.DailyRollingFileAppender
#log4j.appender.file.file=d\:\\log\\info(+).log
#log4j.appender.file.DatePattern= '.'yyyy-MM-dd
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH:mm:ss}][%C{1}:%L] - %m%n
log4j.logger.edu.mvcdemo.controller = debug,controller_logfile
log4j.appender.controller_logfile = org.apache.log4j.DailyRollingFileAppender
log4j.appender.controller_logfile.file=d\:\\log\\controller_logfile.log
log4j.appender.controller_logfile.DatePattern= '.'yyyy-MM-dd
log4j.appender.controller_logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.controller_logfile.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH:mm:ss}][%C{1}:%L] - %m%n
|
#hibernate
hibernate.max_fetch_depth=3
hibernate.jdbc.fetch_size=50
hibernate.jdbc.batch_size=10
hibernate.show_sql=true
hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=true
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
##jdbc
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/jddb?useUnicode=true&characterEncoding=UTF-8
jdbc.username=root
jdbc.password=root
jdbc.maxActive=50
##c3po
c3p0.acquireIncrement=10
c3p0.minPoolSize=3
c3p0.maxPoolSize=200
c3p0.maxIdleTime=6000
|
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。