struts和spring整合
开发流程:
1)引jar包,可以在配置工程中设置用户libarary,然后直接引入。如果在web-inf/lib没有用户导入的lib文件,可以参考问题0的解决方案
需要的是struts_core,spring_core,struts_spring_web
//struts_core
Struts2..32core\commons-fileupload-1.3..jar
Struts2..32core\commons-io-2.2.jar
Struts2..32core\commons-lang3-3.2.jar
Struts2..32core\freemarker-2.3..jar
Struts2..32core\javassist-3.11..GA.jar
Struts2..32core\ognl-3.0..jar
Struts2..32core\struts2-core-2.3..jar
Struts2..32core\xwork-core-2.3..jar
//spring_core
spring3..9core\commons-logging-1.2.jar
spring3..9core\spring-beans-3.2..RELEASE.jar
spring3..9core\spring-context-3.2..RELEASE.jar
spring3..9core\spring-core-3.2..RELEASE.jar
spring3..9core\spring-expression-3.2..RELEASE.jar
//struts_spring_web
struts-spring-web\struts2-spring-plugin-2.3..jar
struts-spring-web\spring-web-3.2..RELEASE.jar
struts-spring-web\spring-webmvc-3.2..RELEASE.jar
2)开发entity/dao/service/action
3)配置Struts2
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>/*</url-pattern>
</filter-mapping>
<!-- struts.xml文件 -->
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd"> <struts>
<package name="Userpkg" extends="struts-default" >
<action name="save" class="userAction" method="saveUser">
<result name="success">/index.jsp</result>
</action>
</package>
</struts>
4)配置bean-dao.xml/bean-service.xml/bean-action.xml文件
<!-- 所有DAO类的配置 -->
<bean id="userDao" class="com.huitong.Dao.impl.UserDao"></bean>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"> <!-- 所有Service类的配置 -->
<bean id="userService" class="com.huitong.service.impl.UserService">
<property name="userDao" ref="userDao"></property>
</bean> </beans>
bean-action.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"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"> <!-- 所有Action类的配置 -->
<bean id="userAction" class="com.huitong.action.UserAction">
<property name="userService" ref="userService"></property>
</bean> </beans>
5)在web.xml文件中配置spring
<!-- 配置spring -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/bean-*.xml</param-value>
</context-param> <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
最后可以测试了,应该是可以通过的
struts2.3.32,spring3.2.9进行整合,
出现问题0:MyEclipse 使用 User Library 不自动部署到 WEB-INF/lib
在项目上右键进入Properties,选择Deployment Assembly,再点击Add...,如下图所示:
2.然后在弹出的窗口中,选择Java Build Path Entries,点击Next,如下图所示:

3.选择你要你引入的UserLibrary,点击Finish即可
出现问题1:java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
解决办法:导包,spring-webmvc-3.2.9.RELEASE.jar
struts和spring整合的更多相关文章
- Struts2框架04 struts和spring整合
目录 1 servlet 和 filter 的异同 2 内存中的字符编码 3 gbk和utf-8的特点 4 struts和spring的整合 5 struts和spring的整合步骤 6 spring ...
- ssh整合之五struts和spring整合
1.首先,我们需要先分析一下,我们的spring容器在web环境中,只需要一份就可以了 另外,就是我们的spring容器,要在我们tomcat启动的时候就创建好了(包括其中的spring的对象),怎么 ...
- struts与spring整合
Spring与Struts框架整合 Spring,负责对象对象创建 Struts, 用Action处理请求 Spring与Struts框架整合, 关键点:让struts框架action对象的创建,交给 ...
- struts+hibernate+spring整合过程常见问题收集
1.java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor缺少asm-3.3.jar2.java.lang.NoClassDefF ...
- java框架之Spring(4)-Spring整合Hibernate和Struts2
准备 导包 Struts2 导入 Struts2 zip 包解压目录下 'apps/struts-blank.war' 中所有 jar 包,如下: asm-3.3.jar asm-commons-3. ...
- Spring整合Struts2框架的第二种方式(Action由Spring框架来创建)(推荐大家来使用的)
1. spring整合struts的基本操作见我的博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2框架整 ...
- Spring整合Struts2框架的第一种方式(Action由Struts2框架来创建)。在我的上一篇博文中介绍的通过web工厂的方式获取servcie的方法因为太麻烦,所以开发的时候不会使用。
1. spring整合struts的基本操作见我的上一篇博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2 ...
- 轻量级Java EE企业应用实战(第4版):Struts 2+Spring 4+Hibernate整合开发(含CD光盘1张)
轻量级Java EE企业应用实战(第4版):Struts 2+Spring 4+Hibernate整合开发(含CD光盘1张)(国家级奖项获奖作品升级版,四版累计印刷27次发行量超10万册的轻量级Jav ...
- struts2,hibernate,spring整合笔记(4)--struts与spring的整合
饭要一口一口吃,程序也要一步一步写, 很多看起来很复杂的东西最初都是很简单的 下面要整合struts和spring spring就是我们的管家,原来我们费事费神的问题统统扔给她就好了 先写一个测试方法 ...
随机推荐
- Eclipse环境安装C/C++插件CDT和Eclipse安装的插件卸载(删除)
http://blog.csdn.net/typa01_kk/article/details/49252513
- nor flash 和nand flash 的区别
ROM和RAM指的都是半导体存储器,ROM是Read Only Memory的缩写,RAM是Random Access Memory的缩写.ROM在系统停止供电的时候仍然可以保持数据,而RAM通常都是 ...
- Sysfs文件系统与Linux设备模型
转:http://www.360doc.com/content/11/1218/16/1299815_173168170.shtml sysfs把连接在系统上的设备和总线组织成为一个分级的目录及文件, ...
- python笔记15-ini配置文件(configparser)
前言 使用配置文件来灵活的配置一些参数是一件很常见的事情,配置文件的解析并不复杂,在python里更是如此,在官方发布的库中就包含有做这件事情的库,那就是configParser configPars ...
- void fun() const{}; const void fun(){}; 和void const fun(){}; 的区别?
void fun() const{}; const void fun(){}; 和void const fun(){}; 的区别? const void fun(){};和void const fun ...
- 剖析ASP.NET Core(Part 3)- UseMvc(译)
原文:https://www.stevejgordon.co.uk/asp-net-core-anatomy-part-3-addmvc 发布于:2017年4月环境:ASP.NET Core 1.1 ...
- java数据库编程——读写LOB、可滚动和可更新的结果集、元数据
java 数据库编程 1. 读写LOB 除了数字.字符串和日期之外,许多数据库还可以存储大对象,例如图片或其它数据.在SQL中,二进制大对象称为BLOB,字符型大对象称为CLOB. 要读取LOB,需要 ...
- vue-resource文档详细解读
Vue可以构建一个完全不依赖后端服务的应用,同时也可以与服务端进行数据交互来同步界面的动态更新.Vue通过插件的形式实现了基于AJAX,JSPNP等技术的服务端通信. vue-resource是一个通 ...
- LeetCode56:Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the arra ...
- 把mysql的数据导出成txt
把mysql的数据导出成txt select a from b into outfile '/sqlfile/a.txt'; my.ini里需要设置secure_file_priv = d:/sqlf ...