webwork将查询数据库后的list显示到JSP中?我将查询出来的数据放到了一个list里面,然后跳转到一个专门放置list的JSP。如果用STRUTS1.2那么只需要在action中写入request.setAttribute("list",list);然后在JSP中直接使用STRUTS标签就可以迭代显示出来了。但是项目现在用WEBWORK,我对WEBWORK一无所知,还望各位多多指教!谢谢!望详细解答!谢谢!

解决方案 »

  1.   

    WEBWORK更简单,一样是用 JSP的语法 ,给你一个例子:Action写法 
     public class RedbagAction extends BasicActionSupport {
      public Redbag getRedbag() {
    return redbag;
    } public void setRedbag(Redbag redbag) {
    this.redbag = redbag;
    }
    private IRedbagService redbagService; private Redbag redbag = new Redbag();
      public String showuse() throws ActionException { HttpServletRequest request = ServletActionContext.getRequest(); String redbagId = ServletUtil.getRequestValue(request, "redbagId"); setRedbag(redbagService.getRedbagById(NumberUtils.toLong(redbagId))); return "showuse";
    } }JSP写法 :
    片段: <tr>
    <td>红包编号:&nbsp;&nbsp;</td>
    <td>${redbag.redbagCode}<input type="hidden" value="${redbag.redbagCode}" name="redbag.redbagCode"></td>
    </tr>也就是说,你可以直接用EL表达式引用到Action设置的变量, 不知道这么说说你明白了吗
    我的新书刚上架,欢迎订购:
    《搜索引擎零距离—基于Ruby+Java搜索引擎原理与实现》 清华出版社。
    http://www.huachu.com.cn/itbook/itbookinfo.asp?lbbh=10105450