SPRING4 Study notes-spring4 integration Struts2

Source: Internet
Author: User

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4A/6F/wKiom1QlGl3BstzmAACWUbGNplE534.jpg "title=" 222222.jpg "alt=" Wkiom1qlgl3bstzmaacwubgnple534.jpg "/>

Person.java

public class Person {private string username;public void Setusername (String username) {this.username = username;}}

Personservice.java

public class Personservice {public void Save () {System.out.println ("Personservice save ...");}}

Personaction.java

public class Personaction {private Personservice personservice;public void Setpersonservice (Personservice Personservice) {this.personservice = Personservice;} Public String Execute () {personservice.save (); return "Success";}}


Applicationcontext.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" xsi: Schemalocation= "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans.xsd "><bean id=" person " class=" Com.spring.beans.Person "><property name= "Username"  value= "Spring" ></property></bean><bean id= "Personservice"  class= " Com.spring.services.PersonService "></bean><!--  Note: The scope property needs to be configured when configuring the Struts2 action in the configuration IOC container. Its value must be prototype --><bean id= "Personaction"  class= "com.spring.actions.PersonAction"   Scope= "prototype" ><property name= "Personservice"  ref= "Personservice" ></property></ Bean></beans> 


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>    < Constant name= "Struts.enable.DynamicMethodInvocation"  value= "false"  />     <constant name= "Struts.devmode"  value= "true"  />         <package name= "Default"  namespace= "/"  extends= "Struts-default" >     <!-- spring Integration Struts2, the class of spring action configured in STRUTS2 needs to only think of the Bean's id -->< in the IOC container Action name= "Personsave"  class= "Personaction" ><result>success.jsp</result></action >    </package></struts> 


Xml

<?xml version= "1.0"  encoding= "UTF-8"? ><web-app xmlns:xsi= "http://www.w3.org/2001/ Xmlschema-instance "xmlns=" Http://java.sun.com/xml/ns/javaee "xsi:schemalocation=" http://java.sun.com/xml/ns/ Javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd "id=" webapp_id " version=" 2.5 ">< display-name>spring_08</display-name><welcome-file-list><welcome-file>index.jsp</ welcome-file></welcome-file-list><!--  Configure the name and location of the spring configuration file  --><context-param>< param-name>contextconfiglocation</param-name><param-value>classpath:applicationcontext.xml</ param-value></context-param><!--  Start servletcontextlistner --><listener> of IOC container <listener-class>org.springframework.web.context.contextloaderlistener</listener-class></ listener><!--  Configuration Struts2 filter --><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> </web-app>


Test page

<a href= "Personsave.action" >personSave.action</a>


HTTP://YUNPAN.CN/CGJJBQGCWUEVQ Extraction Code 2500


This article is from "Avatar" blog, please make sure to keep this source http://shamrock.blog.51cto.com/2079212/1558569

SPRING4 Study notes-spring4 integration Struts2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.