ate3
.HibernateTransactionManager">
< property name="sessionFactory" ref="sessionFactory"/>
< /bean>
< bean id="bookManageService" class="org.springframework.transaction.
interceptor.TransactionProxyFactoryBean">
< property name="transactionManager" ref="transactionManager"/>
< property name="target" ref="bookManageServiceTarget"/>
< property name="transactionAttributes">
< props>
< prop key="add*">PROPAGATION_REQUIRED< /prop>
< prop key="delete*">PROPAGATION_REQUIRED< /prop>
< prop key="update*">PROPAGATION_REQUIRED< /prop>
< prop key="get*">PROPAGATION_REQUIRED,readOnly< /prop>
< /props>
< /property>
< /bean>
< /beans>
谈谈对Struts多模块的认识(4)
时间:2011-03-14
最后我们来把dwr整合进来:
我们在web.xml添加ContextLoaderListener来加载applicationContext-db.xml,applicationContext-dao.xm,applicationContext-service.xml,以及配置DwrServlet:
web.xml:
< ?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">
< 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>
< servlet>
< servlet-name>dwr-invoker< /servlet-name>
< servlet-class>org.directwebremoting.servlet.DwrServlet< /servlet-class>
< init-param>
< param-name>debug< /param-name>
< param-value>true< /param-value>
< /init-param>
< /servlet>
< servlet-mapping>
< servlet-name>dwr-invoker< /servlet-name>
< url-pattern>/dwr/*< /url-pattern>
< /servlet-mapping>
< /web-app>
在dwr.xml中配制bean的创建方式,类型转换,以及Service要暴露的接口:
< dwr>
< allow>
< convert converter="bean" match="edu.jlu.fuliang.domain.Book"/>
< create creator="spring" javascript="BookManageService" >
< param name="beanName" value="bookManageService"/>
< include method="getAllBooks"/>
< include method="getBookByName"/>
< include method="updateBook"/>
< include method="addBook"/>
< include method="deleteBook"/>
< /create>
< /allow>
< /dwr>
最后,我们编写jsp页面index.jsp:
< html>
< head>< title>DWR test< /title>
< script
|