How the JSP gets the value of the object returned in the Struts2 action __js

Source: Internet
Author: User
If you want to upload an object, list, or string from the Struts2 action to the JSP page, simply define the object, list, or string in the action, and then generate the Get,set method. So that the page can be obtained. For example:
public class Loginaction extends actionsupport{
Private user User;//object
private string Username;//String
Publi c list = new LinkedList ()//list public
User GetUser () {return
  user
 }
 public void SetUser (user user) {
  this.user = user
 }
 Public String GetUserName () {return
  username;
 }
 public void Setusername (String username) {
  this.username = username;
 }
 Public List GetList () {return
  list;
 }
 public void setlist (list list) {
  this.list = list;
 }
}


1, JSP page to get the string method
<s:property value= ' message '/> message: string name, must be consistent with action
2, JSP page to get the list of the worthy method, the general list are stored from the database object. Take the following values:
<s:iterator value= "list" status= "St" > list: List name must be consistent with action
<s:property value= "username"/> Gets the value of the Username property of the user object in the list.
</s:iterator>
3.jsp page Gets the value of the property in the object, regardless of whether you want to make changes or check the details, you need to display the object property values that are taken out on the page.
The operation is as follows:
<s:property value= ' user.state '/> User: Object name; State: Object properties. Must remain consistent with the user class.
Related Article

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.