Web Development Learning Note Structs2 Result learning Note (iii) results set with parameters

Source: Internet
Author: User

Result learning Note (iii) results set with parameters Part one: code
Front 

web.xml<struts>    <constant name= "Struts.devmode" value= "true"/>    <package name= "User" Namespace= "/user" extends= "Struts-default" >        <action name= "user" class= " Com.struts2.user.action.UserAction ">    <result type=" redirect ">/user_success.jsp?t=${type}</ result>    </action>        </package>    </struts>
Class Pack Package Com.struts2.user.action;import Com.opensymphony.xwork2.actionsupport;public class Useraction extends actionsupport {private int type;public int GetType () {return type;} public void SetType (int type) {this.type = type;} @Overridepublic String Execute () throws Exception {return "Success";}}

Show 
Part II: Analysis
1.<li><a href= "user/user?type=1" > Parameters </a></li>, link access to user action inside the user namespace, And the action is passed the parameter type = 1;
2.<package name= "user" namespace= "/user" extends= "Struts-default" >  <action name= "user" class= " Com.struts2.user.action.UserAction ">    <result type=" redirect ">/user_success.jsp?t=${type}</ result>  </action>      </package>   <result type= "redirect" >/user_success.jsp?t=${ Type}</result>
Objective:the user Action object is constructed with the data configuration file and the parameters are set. When a request is made by a client, the value passed in the request is passed to the constructed object when the Useraction object is constructed by the configuration file of Web. Xml. Note: The request has only one value stack at a time.
Result requires <result type= "redirect" >/USER_SUCCESS.JSP?T=${TYPE}</RESULT>, requires redirection to user_success.jsp, and requires removal
The type value in the action. where type= "Redirect" means that the client jumps,
3.from valuestack: <s:property value= "T"/><br/>//from value stack from  actioncontext: <s:property value= "# PARAMETERS.T "/><span style=" White-space:pre "></span>//take value from Actioncontext




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.