maven配置文件

	<!-- servlet -->
  	<dependency>
		<groupId>javax.servlet</groupId>
		<artifactId>javax.servlet-api</artifactId>
		<version>3.0.1</version>
	</dependency>

	<!-- Spring-context -->
	<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.2.2.RELEASE</version>
    </dependency>
    <!-- spring web -->
    <dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-web</artifactId>
		<version>4.2.2.RELEASE</version>
	</dependency>

	<!-- struts -->
	<dependency>
    	<groupId>org.apache.struts</groupId>
    	<artifactId>struts2-core</artifactId>
    	<version>2.3.24.1</version>
	</dependency>

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

spring配置文件

<?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-3.0.xsd"
    default-autowire="byType">

	<bean id="mydata" class="webapp.Data">
		<property name="name" value="tian"></property>
		<property name="age" value="23"></property>
	</bean>
</beans>

struts配置文件

<?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>
     <package name="default" namespace="/" extends="struts-default">
        <action name="login" class="mydata" method="execute">
            <result name="success">index1.jsp</result>
        </action>
     </package>
</struts>

web.xml配置文件

  <!-- struts配置 -->
  <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>

  <!-- spring配置 -->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <!-- spring 配置文件 -->
  <context-param>
     <param-name>contextConfigLocation</param-name>
     <param-value>WEB-INF/classes/applicationContext.xml</param-value>
  </context-param>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

Data.Class

public class Data {

	String name;
	int age;
	public void setName(String name)
	{
		System.out.println(name);
		this.name=name;
	}
	public String getName()
	{
		return name;
	}
	public void setAge(int age)
	{
		System.out.println(age+"------------------------------------");
		this.age=age;
	}
	public int  getAge()
	{
		return age;
	}
	public String execute()
	{
		ActionContext.getContext().getApplication().put("name",name);
		ActionContext.getContext().getApplication().put("age", age);
		ActionContext.getContext().getSession().put("name",name);
		ActionContext.getContext().getSession().put("age", age);

		System.out.println(name+age);
		return "success";
	}
}

index.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
hello boy

	<form action="login.action" method="post">
		<input type="text" name="name" id="name"></input>
		<input type="text" name="age" id="age">
		<input type="submit" name="sub" value="提交">
	</form>
	<%
		out.println("hello JSP");
		String str="hello ";
	%>
	<%=str %>

	<%
		out.println("jdf<br>");

		application.setAttribute("hello", "hello");
	%>

</body>
</html>

index1.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

 <%@ taglib prefix ="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
hello boy

	<form action="TestServlet" method="get">
		<input type="text" name="name" id="name"></input>
		<input type="submit" name="sub" value="提交">
	</form>
	<%
		out.println("hello JSP");
		String str="hello ";
	%>
	<%=str %>

	<%
		out.println("jdf<br>");
	%>

	<%
		String string=request.getParameter("name");
		out.println(string);
		String hello=request.getParameter("age");
		out.println(hello);
	%>
	<br>
	<h1>ok</h1>
	<%
		String name=(String)application.getAttribute("name");
		Integer age=(Integer)application.getAttribute("age");
		out.println(name);
		out.println(age);
	%>
	<s:property value="name"/>
	<s:property value="age"/>
	<h1>ok</h1>
	<%
	String string1=(String)session.getAttribute("name");
	out.println(string1);
	Integer hello1=(Integer)session.getAttribute("age");
	out.println(hello1);
	%>
</body>
</html>

eclipse-整合struts和spring-maven的更多相关文章

  1. 条理清晰的搭建SSH环境之整合Struts和Spring

    上文说到搭建SSH环境所需三大框架的jar包,本篇博客将通过修改配置文件整合Struts和Spring,下篇博客整合Hibernate和Spring即可完成环境搭建. 1.声明bean,新建TestA ...

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

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

  3. (转)Maven学习总结(六)——Maven与Eclipse整合

    孤傲苍狼只为成功找方法,不为失败找借口! Maven学习总结(六)——Maven与Eclipse整合 一.安装Maven插件 下载下来的maven插件如下图所示:,插件存放的路径是:E:/MavenP ...

  4. Maven学习总结(6)——Maven与Eclipse整合

    Maven学习总结(六)--Maven与Eclipse整合 一.安装Maven插件 下载下来的maven插件如下图所示:,插件存放的路径是:E:/MavenProject/Maven2EclipseP ...

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

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

  6. Maven+Struts+Hibernate+Spring简单项目搭建

    这段时间学习如何使用Maven+Struts+Hibernate+Spring注解方式建立项目,在这里感谢孙宇老师.    第一次写博客,主要是方便自己查看,同时分享给大家,希望对大家有所帮助,我也是 ...

  7. struts2+hibernate-jpa+Spring+maven 整合(1)

    1.0.0 struts2 与 spring 的整合. 1.1.0 新建maven工程 , 编写pom.xml ,这里只需要简单的添加 一个组件就够了: 在myeclipse 生成的pom.xml 添 ...

  8. Struts2框架04 struts和spring整合

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

  9. Maven学习总结(六)——Maven与Eclipse整合

    一.安装Maven插件 下载下来的maven插件如下图所示:,插件存放的路径是:E:/MavenProject/Maven2EclipsePlugin

  10. spring3+struts2+hibernate3整合出现的问题,No mapping found for dependency [type=java.lang.String, name='struts.objectFactory.spring.enableAopSupport']

    七月 11, 2016 3:49:24 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin警告: [SetPropertiesRule ...

随机推荐

  1. 21 viewPager--- hzScrollView ----llContainer

    结构: MainActivity.java package com.qf.day21_hsviewpagerfragment_demo5; import java.util.ArrayList; im ...

  2. 4.0、Android Studio配置你的构建

    Android构建系统编译你的app资源和源码并且打包到APK中,你可以用来测试,部署,签名和发布.Android Studio使用Gradle,一个高级的构建套件,来自动化和管理构建进程,同时可以允 ...

  3. UNIX网络编程——利用ARP和ICMP协议解释ping命令

    一.MTU 以太网和IEEE 802.3对数据帧的长度都有限制,其最大值分别是1500和1492字节,将这个限制称作最大传输单元(MTU,Maximum Transmission Unit)      ...

  4. Android开发学习之路--UI之简单聊天界面

    学了很多的ui的知识,这里就来实现个聊天的界面,首先来实现个layout的xml,代码如下: <?xml version="1.0" encoding="utf-8 ...

  5. Android开发学习之路--Activity之Intent

    窗外再次飘起了小雪,还有1周就过年了,2016年即将到来,来年不知道自己将身处何处,船到桥头自然直吧.还是继续学习吧,上次学习了Activity,那么如果是两个Activity之间,怎么从一个Acti ...

  6. Android的搜索框SearchView的用法-android学习之旅(三十九)

    SearchView简介 SearchView是搜索框组件,他可以让用户搜索文字,然后显示.' 代码示例 这个示例加了衣蛾ListView用于为SearchView增加自动补全的功能. package ...

  7. 上海C++游戏服务器群活动PPT下载

    下载页面: http://download.csdn.net/download/jq0123/8227519 跨服与跨区的设计PPT 上海C++游戏服务器群 2014.11.9 沙龙讲义. 自我介绍 ...

  8. Access数据类型和.NET数据类型映射

    下表列出了 Microsoft Access 和这些数据类型与 Microsoft.NET Framework 数据类型与 OleDbType 枚举的方式中使用的最常见的数据类型. 访问类型名称 数据 ...

  9. Android动画深入分析

    动画分类 Android动画可以分3种:View动画,帧动画和属性动画:属性动画为API11的新特性,在低版本是无法直接使用属性动画的,但可以用nineoldAndroids来实现(但是本质还是vii ...

  10. 采购申请 POCIRM-001:ORA-01403: 未找到任何数据

    今天同事让帮忙看一个问题,在销售模块提交销售订单生成采购订单的请求时报错 查看请求日志 +------------------------------------------------------- ...