六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 42|回复: 0

常用的JSP页面存取值

[复制链接]

升级  70%

9

主题

9

主题

9

主题

童生

Rank: 1

积分
35
 楼主| 发表于 2013-1-26 14:47:58 | 显示全部楼层 |阅读模式
从Action中取值在jsp中选中checkbox
ActionForm中:
String[] dcid; getSet();
 
Action中:
Map<Long,String> dcInfos;
request.setAttribute("dcInfos", dcInfos);

<c:forEach items="${requestScope.request中的Map集合}" var="dcInfo">      
 <input type="checkbox" id="dcid_${dcInfo.key}" name="dcid" value="${dcInfo.key}"/>${dcInfo.value } 
</c:forEach>
<c:forEach var="dcidValue" items="${paramValues.属性}">
    document.getElementById("dcid_" + <c:out value="${dcidValue}"/>).checked = true;
</c:forEach>

单选按钮radio
<c:forEach items="${requestScope.stores}" var="store">
 <input type="radio" name="storeId" value="${store.storeId}" <c:if test="${store.storeId eq merchantItemSearchForm.storeId}"> checked </c:if> />${store.storeName}
</c:forEach> 

下拉列表select
<select name="itemState" id="itemStateId" onchange="seachByStates(this)">
 <option value="-1">请选择商品状态</option>
 <c:forEach items="${ITEM_STATE_MAP}" var="entry">
  <c:if test="${entry.key != ITEM_STATE_DEL}">
   <option value="${entry.key}" <c:if test="${merchantItemSearchForm.itemState eq entry.key}">selected</c:if>>${entry.value}</option>
  </c:if>
 </c:forEach>
</select>
 
JSP页面格式输出日期
(new Date()).parse(content.updateTimeDate).format('yyyy-mm-dd hh:nn:ss')
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表