zoukankan      html  css  js  c++  java
  • 【131031】html:hidden的使用

    一般来说,我们在使用Struts时,如果要在JSP隐式的传值给Action有两种情况:

    1、要传的值是FromBean中的一个字段,你说的情况应该就是这种情况,例如需要在Edit页面中保存theID,在Action中执行Update操作时根据ID来更新数据库的值,你可以这样做:

    Jsp中的代码为:<html:hidden property="theID" />

    提交后,theID的值就会放到FormBean中的theID中,你就可以通过getTheID()来获得这个值。

    2、要传的值不是FromBean中的一个字段:

    Jsp中的代码为:

    <input type="hidden" name="XXX" value="<%=request.getAttribute(XXX)%>">

    当然,你应该在Action中就已经就这个值放到了request中,request.setAttribute("XXX",value);, 然后在Action中你才可以通过request.getParameter("XXX");来取得这个值。
    补充一点,request.setAttribute("XXX",value);中,value应该是个String,还有,

    <input type="hidden" name="XXX" value="<%=request.getAttribute(XXX)%>">

    应该改为

    <input type="hidden" name="XXX" value="<%=(String)request.getAttribute(XXX)%>">

  • 相关阅读:
    POJ 3071 概率DP
    BZOJ 2427 /HAOI 2010 软件安装 tarjan缩点+树形DP
    POJ 1155 树形DP
    POJ 3252 组合数学?
    POJ 3641 快速幂
    POJ 3180 Tarjan
    POJ 3185 DFS
    POJ 3260 DP
    POJ 2392 DP
    99. Recover Binary Search Tree
  • 原文地址:https://www.cnblogs.com/husam/p/3684013.html
Copyright © 2011-2022 走看看