81,092
社区成员
发帖
与我相关
我的任务
分享
先把数组传到JSP中,然后在JAVASCRIPT中处理.在<body onLoad="">中加载处理的方法.不知道适用不?
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
String[] arr = { "a", "b", "c" };
request.setAttribute("arr", arr);
String[] arrDb = { "a", "b", "c", "d" }; //注意元数据,例如从数据库取出来
request.setAttribute("arrDb", arrDb);
return new ActionForward("/index.jsp");
}
<c:forEach items="${arrDb}" var="db">
<input type="checkbox" name="cb1" value="db" <c:if test='${fn:contains(arr,db)}'>checked="true" </c:if>/>${db} <br />
</c:forEach>