三大框架(ssh)整合之配置文件
2016-12-19 18:20
381 查看
一.web配置文件web.xml
二.Struts2的配置文件struts.xml
<!--拦截器的配置(如果有需要)--!>
<!--全局视图的配置(如果有需要)--!>
三.Spring的配置文件applicationContext.xml
四.hibernate的配置文件(已经整合到了Spring的配置文件中了,也可单独配置hibernate-cfg.xml文件,然后配置到sessionFactory中)
<!-- 解决session延迟加载 -->
<filter>
<filter-name>openSessionInView</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>openSessionInView</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 加载spring配置文件 -->
<context-param>
<param-name>contextConfigLocation&l 4000 t;/param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!--上下文加载监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--struts核心过滤器 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
二.Struts2的配置文件struts.xml
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.objectFactory" value="spring" />
<!--配置国际化的消息提示--!>
<constant name="struts.custom.i18n.resources" value="login-message" />
<package name="defaultPackage" extends="struts-default">
<!--拦截器的配置(如果有需要)--!>
<interceptors>
<interceptor name="loginIntercepter"
class="com.wuhan.bos.web.filter.LoginFilterInterceptor">
<param name="excludeMethods">login</param>
</interceptor>
<interceptor-stack name="myStack">
<interceptor-ref name="loginIntercepter"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="myStack"></default-interceptor-ref>
<!--全局视图的配置(如果有需要)--!>
<global-results>
<result name="login">/login.jsp</result>
<result name="unauthorizedUrl">/unauthorized.jsp</result>
</global-results>
<!--异常结果视图(如果有需要)--!>
<global-exception-mappings>
<exception-mapping result="unauthorizedUrl"
exception="org.apache.shiro.authz.UnauthorizedException"></exception-mapping>
</global-exception-mappings>
</package>
</struts>
三.Spring的配置文件applicationContext.xml
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:tool="http://www.springframework.org/schema/tool"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/tool
http://www.springframework.org/schema/tool/spring-tool-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
">
<!-- 开启spring注解开发 -->
<context:component-scan base-package="com.wuhan.bos" />
<!-- 加载jdbc配置文件 -->
<context:property-placeholder location="classpath:jdbc.properties" />
<!-- 开启事务注解 -->
<tx:annotation-driven transaction-manager="txManager" />
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!--工厂bean (已经整合了hibernate)-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">false</prop>
</props>
</property>
<!--配置hibernate映射 -->
<property name="mappingDirectoryLocations">
<list>
<value>classpath:com/wuhan/bos/domain</value>
</list>
</property>
</bean>
<!-- c3p0数据源 dataSource -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${driverClass}"></property>
<property name="jdbcUrl" value="${jdbcUrl}"></property>
<property name="user" value="${user}"></property>
<property name="password" value="${password}"></property>
</bean>
<!-- 远程调用服务 -->
<bean id="customerService"
class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
<property name="serviceInterface" value="cn.itcast.crm.service.CustomerService" />
<property name="serviceUrl" value="http://localhost:8080/crm/remoting/customer"></property>
</bean>
</beans>
四.hibernate的配置文件(已经整合到了Spring的配置文件中了,也可单独配置hibernate-cfg.xml文件,然后配置到sessionFactory中)
相关文章推荐
- SSH三大框架整合后的配置文件详解
- 三大框架SSH(struts2+spring+hibernate)整合时相关配置文件的模板
- 三大框架SSH(struts2+spring+hibernate)整合时相关配置文件的模板
- 关于SSH三大框架整合——配置文件方式、配置文件+注解方式
- SSH三大框架整合使用的配置文件 注解实现
- 三大框架SSH(struts2+spring+hibernate)整合时相关配置文件的模板
- SSH之三大框架整合配置文件
- ssh三大框架整合配置文件及测试代码
- SSH三大框架整合配置详细步骤(1)
- 框架SSH整合的配置文件
- 最新的三大框架整合之配置文件详解
- SSH三大框架整合配置详细步骤(3)
- SSH三大框架的配置文件笔记
- 三大框架整合文件配置
- 框架 day39-42 SSH整合练习项目CRM(配置文件,增删改查,ajax,上传/下载,分页,BaseDao/Action,MD5)
- SSH三大框架整合配置详细步骤(3)
- 学习三大框架Struts2 、 Hibernate 、 Spring时,涉及到三大框架的配置文件以及整合。
- Spring ,Springmvc,mybatis三大框架整合的配置文件支持
- SSH三大框架整合配置详细步骤(1)
- ssh三大框架整合的配置