shh环境配置——Spring与struts整合
2017-05-06 11:04
423 查看
首先加入Struts包,其次配置web.xml,再者写action类,接着配置action.xml,然后引入Struts.文件配置。最后发布测试。
第一步引入包
第二步
1.struts核心过滤器
<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>
2.spring监听器。
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:bean.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
3.引入配置action.xml
<bean id="userAction" class="cn.itcast.web.UserAction" scope="prototype">
<property name="userService" ref="userService"></property>
注意设置Scope=“prototype”
4.配置Struts.xml
<struts>
<!-- 常量配置 -->
<!-- 1.struts 使用简单样式主题-->
<package name="user" extends="struts-default">
<action name="user_*" class="userAction" method="{1}">
<result name="success">/index.jsp</result>
</action>
</package>
</struts>
第一步引入包
第二步
1.struts核心过滤器
<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>
2.spring监听器。
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:bean.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
3.引入配置action.xml
<bean id="userAction" class="cn.itcast.web.UserAction" scope="prototype">
<property name="userService" ref="userService"></property>
注意设置Scope=“prototype”
4.配置Struts.xml
<struts>
<!-- 常量配置 -->
<!-- 1.struts 使用简单样式主题-->
<package name="user" extends="struts-default">
<action name="user_*" class="userAction" method="{1}">
<result name="success">/index.jsp</result>
</action>
</package>
</struts>
相关文章推荐
- shh整合后web.xml、spring配置文件和struts.xml的内容
- shh整合后web.xml、spring配置文件和struts.xml的内容
- Struts 2+Spring 3+Hibernate 3.3 在MyEclipse 10环境下的整合配置
- Struts 2+Spring 3+Hibernate 4 在MyEclipse 2014环境下的整合配置
- Struts 2+Spring 3+Hibernate 3.3 在MyEclipse 10环境下的整合配置
- Struts2+Hibernate3.2+Spring 2.0整合应用配置
- 手把手struts2.0+hibernate3.1+spring2.0环境配置和实验指导
- Spring+Struts+Hibernate框架整合配置
- struts hibernate spring 环境配置时出现 HTTP Status 404 Servlet action is not available (解决方法)
- 搭建和配置Spring与jdbc整合的环境
- Spring+Hibernate如何配置数据源(Struts Spring Hibernate (SSH) 整合实例)
- Myeclipse开发struts+hibernate+spring新手入门---环境配置
- 【SSI开发总结.7】Struts+Spring+Ibatis环境配置(二)
- struts + spring + hibernate整合事务配置的问题(请教高手)
- spring2.5+struts2.1.8+hibernate3整合配置
- 搭建和配置Spring与Hibernate整合的环境
- Struts,hibernate,Spring整合开发各层之间联系的配置说明(初学者值得看下)
- SSH学习笔记之关于struts-spring-hibernate整合配置问
- Flex2与Struts整合配置 -续搭建免费的flex开发环境flashdevelop
- 【SSI开发总结.6】Struts+Spring+Ibatis环境配置(一)