环境:JDK1.6
IDE: MyEclipse6.1
jar:spring2.5.6,struts2-spring-plugin-2.2.1.jar等
步骤:
新建一个web project后,需作以下修改
1,修改web.xml ,添加listener后的如下:
<?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">
<display-name>integration_web</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<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>/*</url-pattern>
</filter-mapping>
</web-app>
2,修改applicationContext.xml
...
3,修改struts.xml
...
注意:如果将struts的Action交由spring来管理,则
struts action中的"class"应在spring中配置:
<action name="edit" class="editAction" method="input">
<result name="input">/edit.jsp</result>
</action>
如applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="editService" class="org.apache.struts.edit.service.EditServiceInMemory" />
<!--Spring default the scope is "single",the struts2 action is thread safty,so it's set prototype here for struts2 action-->
<bean id="editAction" class="org.apache.struts.edit.action.EditAction" scope="prototype">
<property name="editService" ref="editService" />
</bean>
</beans>
即可;
但在这里,我遇到了一个额外的问题,
tomcat启动时出现的 严重: Error listenerStart
经过配置tomcat的log4j后,打印出来的错误才让知道原来是applicationContext.xml放错了位置。
applicationContext.xml需要放在跟web.xml同一级目录下。
在Tomcat中Log4j的配置如下:
以Tomcat5.5为例,tomcat5.5在默认情况下,并不会自动记录日志信息,需要人为配置。
1、在tomcat安装目录的common/classes中建立一个属性文件log4j.properties
2、在文件中写入日志的信息及日志记录的等级:
3、将log4j.jar和commons-logging.jar添加到tomcat目录下的common/lib目录中
4、完成
分享到:
相关推荐
hibernate3.3.2+spring2.5.6+struts2.1.6整合包,hibernate3.3.2+spring2.5.6+struts2.1.6整合包+anntations
spring2.5.6 整合struts2.0 spring2.5.6 整合struts2.0 spring2.5.6 整合struts2.0
hibernate3,spring2.5.6,struts 2 整合jar包
spring2.5.6+struts2.1.6+hibernate3.3.2+mysql驱动包 所需jar集合
包含 Struts2.1.6 + Spring2.5.6 + Hibernate3.3.2 整合的包。
spring2.5.6 +struts2.1.8+hiernate3.3.2(jar)
spring 2.5.6 + struts 2.2.1 + hibernate 3.5.5 内有 AOP 的切面、全部的注解的 M V C 结构,之外还在上网上找了一个同学的学习笔记一起打包,感觉好不错!
hibernate(jpa) spring2.5.6 struts2.1.8整合开发需要的所有jar包包括tiles框架的jar包
struts2.1.8.1+spring2.5.6+hibernate3.5.6整合注解,测试环境使用myeclipse2014,jdk6,javaee6
Spring2.5.6+struts2.1.8+hibernate3.3.2框架集成模板
Struts2.0.14+Spring2.5.6+Struts.1.3.8+Hibernate3.2,这里集合了struts,hibernate,Spring的核心包,都是核心的,重要文件
这是一个spring2.5.6+struts2.2.3+hibenate3.2的例子。是用annotation实现的。
spring2.5.6与hibernate3.3整合示例,导入即可运行。运用注解、hibernateTemplate、声明式事务管理。包括所有需要jar包。
struts-2.3、spring2.5.6、hibernate3.3整合示例,源码,导入可运行
Struts2.1.8+Spring2.5.6+hibernate3.2.3整合
Struts2.1.6+Spring2.5.6+Hibernate3.3.1整合 步骤非常详细,每步都有说明!
struts2.1.8 + spring2.5.6 + hibernate3.3.2整合,可以看一下,比较完全
Struts2.2+Hibernate3.3+Spring2.5.6整合 一个简单的CRUD案例
struts2.1.8+spring2.5.6+hibernate3.3.2整合项目开发 比较完整哦 可以作为模板的
Struts2.1.6 +Spring2.5.6 + Hibernate3.3.2整合包