Struts2 + Spring + Hibernate 整合 web.xml的一般配置
2015-01-29 14:50
686 查看
Struts2 + Spring + Hibernate 整合 web.xml的一般配置
分类:java2009-07-19 20:38 阅读(1281)评论(0)编辑删除
web.xml的配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml,
/WEB-INF/applicationContext-servlet.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<!-- .....spring mvc....
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
-->
<filter>
<filter-name>osivFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>osivFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- struts... -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--
<filter>
<filter-name>sprint security</filter-name>
<filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>
<init-param>
<param-name>targetClass</param-name>
<param-value>org.acegisecurity.util.FilterChainProxy</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>sprint security</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
Spring配置文件:
<?xml version="1.0" encoding="utf8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/jdbc.properties" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.url}"
p:username="${jdbc.user}"
p:password="${jdbc.password}" />
<!--
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="com.mysql.jdbc.Driver"
p:url="jdbc:mysql://localhost:3306/abcde"
p:username="root"
p:password=""
></bean>
-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/vkeysoft/citiao/entity</value>
</list>
</property>
<!--
<property name="mappingResources">
<list>
<value>vkeysoft/citiao/entity/RegUser.hbm.xml</value>
</list>
</property>
-->
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
hibernate.show_sql=true
hibernate.format_sql=false
hibernate.query.substitutions=true 1, false 0
hibernate.jdbc.batch_size=20
hibernate.hbm2ddl.auto=update
</value>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>
相关文章推荐
- struts2整合spring 时web.xml的配置
- Spring整合Hibernate的XML文件配置,以及web.xml文件配置
- struts2与spring整合web.xml加入的配置
- SpringMVC+Hibernate+jQuery+js+css+jsp+nginx整合时,(1)jsp引入js,css无效;(2)插入数据库时某字段为空;(3)web.xml配置完后,从数据库读数
- spring整合struts2之web.xml配置
- SSH框架整合的时候 在web.xml中需配置的spring信息与struts2的配置信息
- struts2,hibernate,spring三大框架整合的注册程序(xml 配置,mysql数据库)
- 关于搭建restful web service + springMVC + ibatis/hibernate的整合和XML配置意思和ssh+springMVC框架搭建
- ssh整合!Struts.xml、hibernate与spring整合的applicationContext.xml、web.xml文件的配置!
- SSH开发环境的配置:web.xml、Spring集成hibernate和Spring集成Struts2
- spring+hibernate整合web.xml、applicationContext.xml配置
- Java Web开发之Struts2与Spring、Hibernate三者整合
- Struts+Spring+Hibernate实现上传下载(spring的最低框架配置,web.xml等)
- shh整合后web.xml、spring配置文件和struts.xml的内容
- web.xml 文件中一般包括 servlet, spring, filter, listenr的配置。那么他们是按照一个什么顺序加载呢?
- Hibernate与Spring整合,配置文件applicationContext.xml
- 关于flex和spring+hibernate整合web.xml的错误
- spring和struts2的web.Xml配置(spring的web加载)
- CXF之用spring整合web项目时, web.xml配置实例
- spring整合hibernate(注解、xml)applicationContext.xml配置