您的位置:首页 > 其它

ssh框架简洁整合过程

2011-12-07 23:50 281 查看
ssh框架整合过程,包含struts1,struts2,hibernate,spring的框架整合过程,整合步骤如下:

0、在web.xml中增加spring配置、struts1、struts2:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring.xml</param-value>
</context-param>
在web.xml中添加struts1的配置:
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
在web.xml中添加struts2的配置:
<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>*.action</url-pattern>
</filter-mapping>
1、在s1、s2、h3上添加springjar包和struts2-spring-plugin.jar,添加spring配置文件:applicationContext.xml。
2、在applicationContext.xml添加dataSource、sessionFactory、AOP、事务等。
3、在struts-config.xml中增加spring的plugin(struts1):
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property value="classpath:applicationContext.xml" property="contextConfigLocation"/>
</plug-in>
4、修改struts.xml和struts-config.xml中action配置,使用spring统一管理。
type="org.springframework.web.struts.DelegatingActionProxy"
5、消除spring和hibernate的冲突包
6、添加dao、services、biz等包中方法的实现
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: