SSH配置

配置一个数据源;
配置一个sessionFactory,属性为数据源,里面装载hibernate映射文件;
配置一个事务管理器,属性为sessionFactory;
配置一个事务拦截器,属性为事务管理器,及各种传播属性;
最后配置一个Bean自动生成代理,属性为service列表及事务拦截器列表。

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

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.tomcat.dbcp.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@192.168.8.238:1521:ORCL</value>
</property>
<property name="username">
<value></value>
</property>
<property name="password">
<value></value>
</property>

<property name="maxActive">
<value>3</value>
</property>

<property name="defaultAutoCommit">
<value>false</value>
</property>
</bean>

<!--如果用的是XML配置文件,sessionFactory用这个配置 "org.springframework.orm.hibernate3.LocalSessionFactoryBean" -->
<!--如果用的是Annotation配置,sessionFactory用这个配置 "org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref ="dataSource"/>
<property name="mappingResources">
<list>
<value>xx/xx/xx/Model/hbm/Company.hbm.xml</value>
</list>
</property>

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle10gDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>


<!-- 配置事务 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>

<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<!-- 事务拦截器bean需要依赖注入一个事务管理器 -->
<property name="transactionManager" ref="transactionManager"/>
<property name="transactionAttributes">
<!-- 下面定义事务传播属性-->
<props>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="edit*">PROPAGATION_REQUIRED</prop>
<prop key="del*">PROPAGATION_REQUIRED</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>

<!-- 定义BeanNameAutoProxyCreator-->
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<!-- 指定对满足哪些bean name的bean自动生成业务代理 -->
<property name="beanNames">
<!-- 下面是所有需要自动创建事务代理的bean-->
<list>
<value>baseService</value>
</list>
<!-- 此处可增加其他需要自动创建事务代理的bean-->
</property>
<!-- 下面定义BeanNameAutoProxyCreator所需的事务拦截器-->
<property name="interceptorNames">
<list>
<!-- 此处可增加其他新的Interceptor -->
<value>transactionInterceptor</value>
</list>
</property>
</bean>
</beans>


Struts

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>

<!--载入默认的struts配置-->
<include file="struts-default.xml" />

<!--指定web应用的默认编码集,相当于调用HttpServletRequest的setCharacterEncoding方法-->
<constant name="struts.i18n.encoding" value="UTF-8"></constant>

<!--该属性指定需要Struts 2处理的请求后缀,该属性的默认值是action,即所有匹配*.action的请求都由Struts 2处理
如果用户需要制定多个请求后缀,则多个后缀之间以英文逗号隔开-->
<constant name="struts.action.extension" value="action,do"></constant>

<!--设置浏览器是否缓存静态内容,默认值为true,生产环境下使用,开发阶段最好关闭 -->
<constant name="struts.serve.static.browserCache" value="false"></constant>

<!--当struts的配置文件修改后,系统是否自动重新加载该文件,默认值为false,生产环境下使用,开发阶段最好打开 -->
<constant name="struts.configuration.xml.reload" value="true"></constant>

<!--开发模式下使用,可以打印出更详细的错误信息 -->
<constant name="struts.devMode" value="true" />

<constant name="struts.enable.DynamicMethodInvocation" value="false" />

<!-- 默认的视图主题 -->
<constant name="struts.ui.theme" value="simple"></constant>

<!--Struts2集成Spring:所有action对象有Spring来负责创建-->
<constant name="struts.objectFactory" value="spring"></constant>

<!--载入信息配置文件-->
<constant name="struts.custom.i18n.resources" value="messageResource"></constant>

<!--下面载入各个业务的Action-->
<package name="Wap_Test" extends="struts-default">

<!-- 载入测试用的WAP1.1页面Action -->
<action name="wap11" class="wapTestBean" method="doTest">
<result name="success">/Wap/1.1/page/test.jsp</result>
</action>

<!-- 载入测试用的WAP2.0页面Action -->
<action name="wap20" class="wapTestBean" method="doTest">
<result name="success">/Wap/2.0/page/test.jsp</result>
</action>
</package>

<package name="Report_Test" extends="struts-default,jasperreports-default">

<!-- 载入测试用的report页面Action -->
<action name="report" class="reportTestBean" method="doPrint">
<result name="print" type="jasper">
<param name="location">/jasperreport/custinfo.jasper</param>
<param name="dataSource">custinfoList</param>
<param name="format">PDF</param>
</result>
</action>

</package>

<!-- login Interceptor-->
<include file="../conf/interceptors-config.xml" />

<!-- login Action-->
<include file="../conf/struts-WebLogin.xml" />
</struts>


Spring-Dao,在最基础Dao里加入sessionFactory

<?xml version="1.0" encoding="UTF-8"?>
<!-- Dao层的配置信息 -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="baseDao" class="xx.xx.xx.Dao.impl.BaseDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>

<bean id="reportDao" class="xx.xx.xx.Dao.impl.ReportDaoImpl" parent="baseDao">
</bean>
</beans>


Web加载

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">


<display-name>XXSyatem</display-name>
<distributable/>

<!-- Spring ApplicationContext配置文件的路径,可使用通配符*,多个路径用,号分隔,此参数用于后面的Spring-Context loader -->

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/conf/SpringApplicationContext.xml,/WEB-INF/conf/Spring-*.xml</param-value>
</context-param>

<context-param>
<param-name>extremecomponentsPreferencesLocation</param-name>
<param-value>/extremetable.properties</param-value>
</context-param>


<!-- 著名 Character Encoding filter -->
<filter>
<filter-name>encodingFilter</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>
</filter>

<!-- struts2 滤镜配置 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-plugin.xml,../conf/struts.xml</param-value>
</init-param>
</filter>


<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter>
<filter-name>eXtremeExport</filter-name>
<filter-class>org.extremecomponents.table.filter.ExportFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>eXtremeExport</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!--Spring ApplicationContext 载入 ,必须-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- Spring 刷新Introspector防止内存泄露 -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>

<!-- session超时定义,单位为分钟 -->
<session-config>
<session-timeout>20</session-timeout>
</session-config>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

</web-app>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值