struts的配置文件
- XML code
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"><struts> <constant name="struts.i18n.encoding" value="gbk" /> <constant name="struts.objectFactory" value="spring" /> <package name="default" namespace="/admin" extends="struts-default"> <action name="putInsert" class="purveryAction" method="Insert"> <result name="success">yes.html</result> <result name="error">no.jsp</result> </action> <action name="getAll" class="purveryAction" method="get"> <result name="success">yes.jsp</result> <result name="error">no.jsp</result> </action> <action name="getOne" class="purveryAction" method="get"> <result name="success">yes.jsp</result> <result name="error">no.jsp</result> </action> </package></struts>
spring 的配置文件
- XML code
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"> </property> </bean> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="get*" propagation="REQUIRED" read-only="true" /> <tx:method name="find*" propagation="REQUIRED" read-only="true" /> <tx:method name="search*" propagation="REQUIRED" read-only="true" /> <tx:method name="query*" propagation="REQUIRED" read-only="true" /> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="submit*" propagation="REQUIRED" /> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="insert*" propagation="REQUIRED" /> <tx:method name="del*" propagation="REQUIRED" /> <tx:method name="remove*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="modify*" propagation="REQUIRED" /> <tx:method name="check*" propagation="REQUIRED" /> <tx:method name="do*" propagation="REQUIRED" /> <tx:method name="*" propagation="REQUIRED" read-only="true" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="serviceMethod" expression="execution(* org.benz.action.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod" /> </aop:config> <bean id="purveryDao" class="org.benz.dao.impl.PurveyDaoImpl"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="purveryBiz" class="org.benz.biz.impl.PurveryBizImpl"> <property name="purdao" ref="purveryDao"></property> </bean> <bean id="purveryAction" class="org.benz.action.Purveyactionfrom"> <property name="purveryBiz" ref="purveryBiz"></property> </bean></beans>