开发流程:

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整合的更多相关文章

  1. Struts2框架04 struts和spring整合

    目录 1 servlet 和 filter 的异同 2 内存中的字符编码 3 gbk和utf-8的特点 4 struts和spring的整合 5 struts和spring的整合步骤 6 spring ...

  2. ssh整合之五struts和spring整合

    1.首先,我们需要先分析一下,我们的spring容器在web环境中,只需要一份就可以了 另外,就是我们的spring容器,要在我们tomcat启动的时候就创建好了(包括其中的spring的对象),怎么 ...

  3. struts与spring整合

    Spring与Struts框架整合 Spring,负责对象对象创建 Struts, 用Action处理请求 Spring与Struts框架整合, 关键点:让struts框架action对象的创建,交给 ...

  4. struts+hibernate+spring整合过程常见问题收集

    1.java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor缺少asm-3.3.jar2.java.lang.NoClassDefF ...

  5. java框架之Spring(4)-Spring整合Hibernate和Struts2

    准备 导包 Struts2 导入 Struts2 zip 包解压目录下 'apps/struts-blank.war' 中所有 jar 包,如下: asm-3.3.jar asm-commons-3. ...

  6. Spring整合Struts2框架的第二种方式(Action由Spring框架来创建)(推荐大家来使用的)

    1. spring整合struts的基本操作见我的博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2框架整 ...

  7. Spring整合Struts2框架的第一种方式(Action由Struts2框架来创建)。在我的上一篇博文中介绍的通过web工厂的方式获取servcie的方法因为太麻烦,所以开发的时候不会使用。

    1. spring整合struts的基本操作见我的上一篇博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2 ...

  8. 轻量级Java EE企业应用实战(第4版):Struts 2+Spring 4+Hibernate整合开发(含CD光盘1张)

    轻量级Java EE企业应用实战(第4版):Struts 2+Spring 4+Hibernate整合开发(含CD光盘1张)(国家级奖项获奖作品升级版,四版累计印刷27次发行量超10万册的轻量级Jav ...

  9. struts2,hibernate,spring整合笔记(4)--struts与spring的整合

    饭要一口一口吃,程序也要一步一步写, 很多看起来很复杂的东西最初都是很简单的 下面要整合struts和spring spring就是我们的管家,原来我们费事费神的问题统统扔给她就好了 先写一个测试方法 ...

随机推荐

  1. CentOS 6.9/Ubuntu 16.04搭建OpenVPN服务器以及客户端的使用

    说明: 1.发现一个很奇怪的现象,CentOS和Ubuntu有着对用户不同的管理理念,比如CentOS中安装一切软件都是以root优先(su -),而Ubuntu则以当前用户优先,安装软件以sudo开 ...

  2. 【LaTeX】E喵的LaTeX新手入门教程(4)图表

    这里说的不是用LaTeX画图,而是插入已经画好的图片..想看画图可以把滚动条拉到底.前情回顾[LaTeX]E喵的LaTeX新手入门教程(1)准备篇 [LaTeX]E喵的LaTeX新手入门教程(2)基础 ...

  3. Android 开发之 ---- bootloader (LK)

    LK是什么 LK 是 Little Kernel 它是 appsbl (Applications ARM Boot Loader)流程代码  ,little kernel 是小内核小操作系统. LK ...

  4. Tile based Rendering //后面一段是手机优化建议

    https://www.imgtec.com/blog/a-look-at-the-powervr-graphics-architecture-tile-based-rendering/ 一种硬件结构 ...

  5. ISP图像调试工程师——宽动态增强(熟悉图像预处理和后处理技术)

    宽动态范围图像快速增强算法 : http://www.docin.com/p-1783311889.html

  6. cannot be cast to javax.servlet.Filter 报错, 原因servlet-api.jar冲突

    使用maven开发web应用程序, 启动的时候报错: jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: jav ...

  7. C#动态调用webservice方法

    摘 自: http://www.hao5191.cn/a/chengxukaifa/c_/20130109/115819.html using System; using System.Collect ...

  8. 转: 腾讯Bugly干货分享:Android应用性能评测调优

    转:http://www.kuqin.com/shuoit/20150618/346693.html?utm_source=www.race604.com 前言 在智能手机App竞争越来越激烈的今天, ...

  9. You Gotta Care About the Code

    You Gotta Care About the Code Pete Goodliffe IT DOESN'T TAKE SHERLOCK HOLMES to work out that good p ...

  10. 绿化和卸载 DOS 批处理

    @ECHO OFF&PUSHD %~DP0 &TITLE 绿化和选项 mode con cols= lines= color 2F Rd >NUL Md >NUL||(Ec ...