Dowemo

Http://blog. Csdn. net/outsider_lcg/article/details/44967055.

For the shopping cart project, the project documentation requires that you read the data from the database when you open the first page, and you can use the <s.

<s: action name => ExecuteResult => = '> '

Attribute description: name, the name of the action in the struts. Xml. A ExecuteResult is whether the returned view is loaded into this page, namespace: Action corresponding namespace

Index. Jsp.


<div> 


 <s:action name="goodsAction" executeResult="true" namespace="/action"> 


 </s:action> 


 </div> 






Struts. Xml.

<package name="ssh" extends="struts-default" namespace="/action"> 


<action name="goodsAction" class="orderAction" method="findAllGoods"> 


 <result name="success">/test.jsp</result> 


 </action> 


<package> 






Test. Jsp.

<body> 


 <table border=1 align="center"> 


 <th>id</th><th>商品名称</th><th>数量</th><th>单价</th> 


 <s:iterator value="goods" var="good"> 


 <tr> 


 <td><s:property value="#good.id"/></td> 


 <td><s:property value="#good.goods_name"/></td> 


 <td><s:property value="#good.count"/></td> 


 <td><s:property value="#good.price"/></td> 


 <td><s:a href="action/oneGoodAction?user_id=%{#parameters.user_id}&good_id=%{#good.id}">详情</s:a></td> 


 </tr> 


 </s:iterator> 


 </table> 


 </body> 






Execute the process: after starting tomcat, enter localhost: 8080/XXX/, by default open index. Jsp, which will execute <s: action>, first jump to the corresponding.

After the data is completed, jump to the test. Jsp, and then the result of the test. Jsp is displayed in the div in the index. Jsp.





Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs