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.