spring配置文件都放到src/conf/spring目录中,struts.xml放在src目录下
1、web.xml配置如下
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>b2b.root</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:conf/spring/spring*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>false</param-value> <!--设置成false,才能保证在jsp页面调用Bean中的lazy对象时不会出错-->
</init-param>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
修改struts.xml,
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
<constant name="struts.devMode" value="true"/>
<constant name="struts.i18n.encoding" value="UTF8"/>
<package name="default" namespace="/" extends="struts-default">
<global-results>
<result name="businessError">/pages/errors/BusinessErrorPage.jsp</result>
<result name="dbError">/pages/errors/DBErrorPage.jsp</result>
<result name="httpError">/pages/errors/HTTPErrorPage.jsp</result>
<result name="permissionError">/pages/errors/PermissionErrorPage.jsp</result>
<!-- 当Session失效时,统一转到这个页面 -->
<result name="login" type="redirectAction">Login_input</result>
<result name="json" type="json"></result>
<result name="error">/pages/bp/errorPage.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping result="businessError" exception="XXXException"></exception-mapping>
<exception-mapping result="httpError" exception="XXXXException"></exception-mapping>
</global-exception-mappings>
</package>
<include file="struts_*.xml"/>
</struts>
所有action类都继承 com.opensymphony.xwork2.ActionSupport
分享到:
相关推荐
包含了spring ibatis struts2.0整合需要的jar包 有需要的就下吧
以前整合大多数为struts1.x hibernate spring 现在struts2.x也出来一阵子了,大多公司开始使用struts2.x 所以这就造就了整合问题,此系统能帮助初学都迅速进入状态,迅速上手
应广大网友需求,自己抽了点时间写了一个Struts2.0+Spring2.0+Hibernate3.1的登录及增删改查的完整演示示例,以此奉献给大家,由于本人水平有限,有写的不好的地方还望大家多提宝贵意见,如果有不明白的地方请关注我的...
Spring2.5.3+Struts2.0.11.1+Hibernate3.2.6整合备忘 (转载)
对spring 2.0 + struts 2.0 + hibernate 3.2 进行了系统的整合。
Struts2.0+Spring2.0+Hibernate3.1整合文档
整合了Ibatis+struts2.0+Spring2.5的增、删、改、查和调用存储过程
struts2.0+spring2.0+hibernate3.0整合开发快速入门-4
struts2.0+spring2.5+hibernate3.0整合框架,下载导入到eclipse下即可。。启动tomcat前先修改jdbc.properties文件。由于lib文件较大,所以请自行导入相关lib包。
Struts2.0+Hibernate3.2+Spring2.0整合源码,用的DB是SQL Server 2005 ,jar包里面都有的了.
目的:给学习SSH(Struts2.1.6+Spring2.0+Hibernate3.1)整合的学生。从使用角度看,Struts2的SSH事例比Struts1.x的SSH简单。至于声明式事务部分,你可以参见另外一个资源“Spring 2.0 + Struts 1.2 + Hibernate 3.2 +...
struts2.0 +spring2.0+hiberante3所需jar包
整合spring2.5+hibernate3+struts2.0项目,有完整引入jar包。有注解哦
Struts 2.0 + Hibernate 3.2 + Spring 2.0 框架整合.doc
spring2.5+hibernate3.2+struts2.0整合解析(精典案例),个人强烈推荐!
Spring2.5+Struts2.0+DWR完美整合完成用户登陆模块
开发环境myeclipse和tomcat 服务器。使用struts2.0+spring+hibernate3.0整合
该示例使用MyEclipse 5.5 IDE用来整合四个技术(Struts 1.2, Spring 2.0, Hibernate 3.2和Ajax技术)的轻量级的JavaEE。 操作步骤如下: 1. 下载并解压之后,使用MyEclipse导入工程 2. 找到demo目录中的.sql数据库...
Struts 2 + Spring 2.0 + Hibernate 3.0整合笔记.doc
struts1.2+spring2.0+hibernate3.2整合源码 ,测试通过,jar包冲突已经消除,绝对可用,完整工程的源码,导入即可使用。