三大框架(ssh)整合之配置文件
一.web配置文件web.xml
<!-- 解决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</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>
<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>
<?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/beanshttp://www.springframework.org/schema/beans/spring-beans-3.2.xsdhttp://www.springframework.org/schema/toolhttp://www.springframework.org/schema/tool/spring-tool-3.2.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop.xsdhttp://www.springframework.org/schema/contexthttp://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>
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: 串口通信中ReadFile和WriteFile的超时详解!
- 下一篇: SSM整合的配置文件详解
