1.0.0 struts2 与 spring 的整合.

1.1.0 新建maven工程 , 编写pom.xml ,这里只需要简单的添加 一个组件就够了:

在myeclipse 生成的pom.xml 添加如下代码:

 <dependency><groupId>org.apache.struts</groupId><artifactId>struts2-spring-plugin</artifactId><version>2.3.16</version></dependency>

结果如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>cc.jorcen.msai</groupId><artifactId>mport</artifactId><version>0.0.1-SNAPSHOT</version><packaging>war</packaging><name /><description /><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>org.apache.struts</groupId><artifactId>struts2-spring-plugin</artifactId><version>2.3.16</version></dependency><!-- J2EE COMMONS--><dependency><groupId>javax.servlet</groupId><artifactId>jstl</artifactId><version>1.2</version><scope>provided</scope></dependency><dependency><groupId>javax.servlet.jsp</groupId><artifactId>jsp-api</artifactId><version>2.1</version><scope>provided</scope></dependency><dependency><groupId>org.glassfish</groupId><artifactId>javax.annotation</artifactId><version>3.0.1</version></dependency><dependency><groupId>org.glassfish</groupId><artifactId>javax.ejb</artifactId><version>3.0.1</version></dependency><dependency><groupId>org.jboss.weld</groupId><artifactId>weld-osgi-bundle</artifactId><version>1.0.1-SP3</version></dependency><dependency><groupId>org.glassfish</groupId><artifactId>javax.servlet</artifactId><version>3.0.1</version></dependency></dependencies><build><plugins><plugin><artifactId>maven-war-plugin</artifactId></plugin><plugin><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.6</source><target>1.6</target></configuration></plugin></plugins></build>
</project>

1.2.0 添加spring-application.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:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:p="http://www.springframework.org/schema/p" xmlns:cache="http://www.springframework.org/schema/cache"xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-3.0.xsd   http://www.springframework.org/schema/aop   http://www.springframework.org/schema/aop/spring-aop-3.0.xsd   http://www.springframework.org/schema/tx    http://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.0.xsd"><context:annotation-config  /><context:component-scan base-package="com.sai" /><aop:config /></beans>

1.3.0 添加struts.XML 文件

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN""http://struts.apache.org/dtds/struts-2.3.dtd">
<struts><package name="package-default" namespace="/" extends="struts-default"><action name="*" class="{1}Action" /></package>
</struts>    

1.4.0 添加struts.properties 文件

struts.devMode=true
struts.ui.theme=simple
struts.action.extension=cy,action,do
struts.multipart.maxSize=30485760
struts.i18n.encoding=utf-8
struts.custom.i18n.resources=MessageResource,globalMessage
struts.configuration.xml.reload=false
struts.locale=zh_CN
struts.enable.DynamicMethodInvocation=true
struts.objectFactory=spring

1.5.0 修改web.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"><!-- contextConfigLocation --><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:/spring-*.xml</param-value></context-param><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>*.cy</url-pattern></filter-mapping><display-name></display-name><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list>
</web-app>

1.6.0 添加测试类

package com.sai.test.action;import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;import com.opensymphony.xwork2.ActionSupport;@Controller
@Scope("prototype")
public class TestAction extends ActionSupport {public TestAction() {super();System.out.println(TestAction.class);}@Overridepublic String execute() throws Exception {System.out.println(SUCCESS);ServletActionContext.getResponse().getWriter().print(SUCCESS);return null;}public static void main(String[] args) {System.out.println(TestAction.class);}
}

1.7.0 测试

http://localhost:8080/mport/test.cy

结果

success

到此struts2-spring 集成成功.

struts2+hibernate-jpa+Spring+maven 整合(1)相关推荐

  1. EasyUI、Struts2、Hibernate、spring 框架整合

    经历了四个月的学习,中间过程曲折离奇,好在坚持下来了,也到了最后框架的整合中间过程也只有自己能体会了. 接下来开始说一下整合中的问题和技巧: 1,  jar包导入 c3p0(2个).jdbc(1个). ...

  2. Struts2 Hibernate集成示例教程

    Struts2 Hibernate集成示例教程 Struts2和Hibernate都是各自领域中广泛使用的框架.今天我们将学习如何将Struts2 Web应用程序框架与Hibernate ORM框架集 ...

  3. 【struts2+spring+hibernate】ssh框架整合开发

    SSH框架整合 1 Struts2+Spring+Hibernate导包 Struts2导入jar包: * struts2/apps/struts2-blank.war/WEB-INF/lib/*.j ...

  4. java ee ssh三大框架知识点_详解JAVAEE——SSH三大框架整合(spring+struts2+hibernate)...

    详解JAVAEE--SSH三大框架整合(spring+struts2+hibernate) 发布时间:2020-09-17 13:34:05 来源:脚本之家 阅读:64 作者:kent鹏 一.整合原理 ...

  5. Struts2+Hibernate+Spring 整合示例

    转自:https://blog.csdn.net/tkd03072010/article/details/7468769 Struts2+Hibernate+Spring 整合示例 Spring整合S ...

  6. Struts2、Hibernate、Spring整合所需要的jar包

    Struts2.Hibernate.Spring整合所需要的包: Struts2: struts2-core-2.0.14.jar  -- Struts2的核心包. commons-logging-1 ...

  7. SSH整合(Struts2+hibernate+spring)

    1.创建表 create table t_user(id int primary key auto_increment,username varchar(50),password varchar(32 ...

  8. 孙宇java_[JAVA] 孙宇老师Struts2+Hibernate4+Maven+EasyUI+SpringMvc+Spring+Mybatis+Maven整合课程...

    资源介绍 孙宇老师Struts2+Hibernate4+Maven+EasyUI+SpringMvc+Spring+Mybatis+Maven整合课程 ===============课程目录===== ...

  9. spring+struts2+hibernate整合

    本文介绍   1.Struts2+Spring2.5+Hibernate3.3的整合  2.采用单元测试  3.加入了lob类型的操作配置  4.介绍oralce驱动 本文采用oracle11g  5 ...

最新文章

  1. boost::foreach模块非常量右值的测试程序
  2. pandas清华镜像_一款可以像操作Excel一样玩Pandas的可视化神器来了!
  3. 5 获取当前访问的控制名称_LabVIEW编程技巧:网络通信中如何获取计算机名称、IP地址等信息...
  4. 恒温控制系统单片机仿真c语言,基于51单片机的恒温控制系统
  5. 两道关于回溯法,分支限界法的算法题
  6. mysql read uncomit_mysql配置文件,帮看看
  7. python的前端和后端_前端与后端的数据交互(jquery ajax+python flask)
  8. 微信小程序Axure元件库
  9. html默认半透明遮罩层,css遮罩层 半透明
  10. 计算机控制技术课程2018更新资料
  11. mpp格式文用什么软件打开
  12. 计算机基础实验操作,实验一计算机基础操作 实验报告
  13. 龙芯 Linux usb,使用debirf制作龙芯2F的LiveUSB
  14. LaTeX中实心圆点列表的一点经验
  15. 2022常见软件测试面试题
  16. 佳能Canon MF9200 Series 一体机驱动
  17. 如何制作电子文档CHM(How to gernerate chm from assembly)
  18. 苹果cmsv10仿电影淘淘PC+WAP爱看的高端免费模板
  19. 玩客云当打印机服务器,再玩一次机,我把玩客云改造成了群控系统!
  20. 【IPv6】NS,NA 报文学习

热门文章

  1. java中各种vo举例_了解JAVA中的POJO,Entity,PO,VO,DTO,DM包括代码举例展示
  2. 深度linux添加xp,Linux和Windos XP下向路由表添加路由
  3. Virtex-6中的SelectIO模块
  4. 区跨链应用 | 区块链创业者不要再骗自己了
  5. 强大的vim配置文件,让编程更随意
  6. Html5浏览器支持
  7. 每个优秀程序员必须具备的技能
  8. 动态调用WCF不添加服务(svcutil.exe)
  9. ASPNET服务器控件之一
  10. android LaunchMode之SingleTask