JSP page data interacts with the action data using the navigation map language and set injection

Source: Internet
Author: User

Store the queried data in the session

Public String FindAll () {

List<student> list= Studentbiz.findall ();
HttpServletRequest request=servletactioncontext.getrequest ();
Request.getsession (). SetAttribute ("studentsession", list);
return "Findallsuccess";
}

Take out the data that exists in the session

<s:iterator value= "#session. Studentsession" var= "Slist" >
<tr>
<td> <s:property value= "#slist. Stuid"/></td>
<td> <s:property value= "#slist. Name"/></td>
<td> <s:property value= "#slist. Sex"/></td>
<td> <s:property value= "#slist. Sdate"/></td>
<td> <input name= "button" id= "button" onclick= "doit (' del ', <s:property value=" #slist. Stuid "/>);"
Value= "Delete" class= "Input-button" type= "button"/></td>
<td><a href= "" > Update </a></td>
</tr>
</s:iterator>

Store data in a stacked way

List<categorys> Categorylist=categoryservice.findall ();

Store data store data using a stack-up approach
If you use session to store data, you may need to refresh the page to get data
Servletactioncontext.getrequest (). GetSession ()
Putting data into the stack
Actioncontext.getcontext (). Getvaluestack (). Set ("CategoryList", categorylist);

Take the data () in the JSP page

<s:iterator value= "CategoryList" var= "C" >--------------note there's a different way to get data from the session. Session is using #categorylist
<dl>
<dt>
<a href= "${pagecontext.request.contextpath}/image/vegetables-Powered by Mango team.htm" >
<s:property value= "#c. CName"/>
</a>
</dt>
<s:iterator value= "#c. Categoryseconds" var= "cs" >--------------because what I'm storing here in Java code is the first class category. Level two classification (relationship between database tables)
<dd>
<a>
<s:property value= "#cs. CSName"/>
</a>
</dd>
</s:iterator>
</dl>
</s:iterator>

JSP page data interacts with the action data using the navigation map language and set injection

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.