[Learning] [Java] struts2 and page transfer value

Source: Internet
Author: User

Execute action to process the variables in the class, and then use the strust2 tag to obtain the values of the variables in the action class.

  <%  @ Taglib prefix  =     "  S  "  Uri  =     " /Struts-tags  "     %>  
< Html >
< Head >
< Title > Hello world! </ Title >
</ Head >
< Body >
< H2 > < S: Property Value = "Message" /> </ H2 >
</ Body >
</ Html >

There is a message variable in the action class.

Method 2: implement with valuestack

<%  
// Obtain the valuestack object.
Valuestack = (Valuestack) request. getattribute ( " Struts. valuestack " );
%>
< Html >
< Head >
< Title > Hello world! </ Title >
</ Head >
< Body >
< H2 > <% = Vs. findstring ( " Message " ) %> </ H2 >
</ Body >
</ Html >

struts2 puts the variables in the action class into the valuestack container during execution, and obtains the instance through request. getattribute ("struts. valuestack") on the JSP page. Struts. valuestack should be named as agreed.

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.