eclipse-整合struts和spring-maven
来源:互联网 发布:淘宝号信誉度查询 编辑:程序博客网 时间:2024/05/19 20:39
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>
<!-- 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";}}
<%@ 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>
<%@ 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>
0 0
- eclipse-整合struts和spring-maven
- 整合 Struts 和 Spring
- struts和spring整合
- 整合 Struts 和 Spring
- 整合 Struts 和 Spring
- Spring和Struts整合
- 整合spring 和struts
- spring和struts整合
- spring 和 struts 整合
- struts 和spring 整合
- 整合Struts和Spring
- Spring和Struts整合
- Eclipse 下Struts 2.1.6+ 和spring 2.5.5 整合
- spring和struts整合(转)
- struts和spring的整合
- struts和spring的整合!
- Spring和Struts 2整合
- 【示例】Spring和Struts整合
- QProcess start
- shell 判断式
- 关于Xilinx FSL总线的一些总结
- 【Android策略】Fragment实例化及通过setArguments解决 android.support.v4.app.Fragment$InstantiationException
- LeetCode Course Schedule II 拓扑排序
- eclipse-整合struts和spring-maven
- 表格 标签属性
- Http Requests for PHP
- spring单元测试使用
- 深入理解Java1:SimpleDateFormat安全的时间格式化
- python学习笔记
- 学习笔记—二叉树中求度为2的节点个数
- Mysql日期函数使用汇总
- Java反射知识点总结