疯狂java


您现在的位置: 疯狂软件 >> 新闻资讯 >> 正文

Webwork2 Spring2 Hibernate3, DWR的整合


 1.在web.xml配置webwork的action

<servlet>
<servlet-name>webwork</servlet-name>
<servlet-class>com.opensymphony.webwork.dispatcher.ServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>webwork</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>


2.在web.xml中指定srping的配置文件
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/appContext.xml,/WEB-INF/classes/daoContext.xml,/WEB-INF/classes/actionContext.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

3.在spring的配置文件中配置dataSource, sessionFactory等, 整合hibernate, 省略一万字

4.修改webwork的配置文件webwork.properties
webwork.objectFactory = spring

5.在spring中新建一个bean, class为指定webwork的action所在

<bean name="loginAction" class="angus.action.LoginAction" scope="prototype">
<property name="service" ref="service"/>
</bean>

6.在xwork.xml中新建webwork的action, 并指定class为spring中定义的bean