SpringMVC+Hibernate+Spring整合(一) (二)

2014-11-24 10:55:32 · 作者: · 浏览: 1
PROPAGATION_REQUIRED



< xml version="1.0" encoding="UTF-8" >
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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">














org.hibernate.dialect.MySQLDialect
update
true
true




com.tgb.entity.User














PROPAGATION_REQUIRED,-Exception
PROPAGATION_REQUIRED,-myException
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED




然后配置关于SpringMVC的内容,下面配置中都有注释说明,就不再赘述,spring-mvc.xml放在config.spring包下:


[html] < xml version="1.0" encoding="UTF-8" >
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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">















< xml version="1.0" encoding="UTF-8" >
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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">












完成这些共用的配置之后,来配置web项目起点web.xml:


[html] < xml version="1.0" encoding="UTF-8" >

json_test

login.jsp




contextConfigLocation
classpath*:config/spring/spring-*.xml




org.springframework.web.context.ContextLoaderListener




springMVC
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath*:config/spring/spring-mvc.xml

1


springMVC
/




encodingFilter
org.springframework.web.filter.CharacterEncodingFilter

encoding
UTF-8


forceEncoding
true



encodingFilter
/*




openSession
org.springframework.orm.hibernate4.support.OpenSessionInViewFilter


openSession
/*

< xml version="1.0" encoding="UTF-8" >

json_test

login.jsp




contextConfigLocation
classpath*:config/spring/spring-*.xml




org.springframework.web.context.ContextLoaderListener




springMVC
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath*:config/spring/spring-mvc.xml

1


springMVC
/




encodingFilter
org.springframework.web.filter.CharacterEncodingFilter

encoding