日期:2014-05-16  浏览次数:20312 次

常用的JSP页面存取值

从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')