我有一个带有以下EL / html标记的JSP:
<c:forEach var="key" items="${resource.stringPropertyNames()}"> <tr> <td>${key}</td> <td><input type = "text" name = "${key}" value = "${resource.get(key)}"></td> </tr> </c:forEach>
呈现我的jsp时,第一个<td>标记显示$ {key}的评估值。<input>但是,在标记中,未正确评估$ {key}。当我尝试从servlet(request.getParameter(StringKey))中检索输入作为请求参数时,我得到的文字$key没有花括号。当我这样做时request.getParameter("$key"),我得到${resource.get(key)}在EL 中求值的字符串的多个值。
<td>
<input>
request.getParameter(StringKey)
$key
request.getParameter("$key")
${resource.get(key)}
到底是怎么回事?
编辑
控制器方法(使用弹簧)代码:
@RequestMapping(value = URI_PATH + "{fileName}", method = RequestMethod.GET) public String getProperties(@PathVariable String fileName, ModelMap modelMap) { Properties resource = ..//get properties file modelMap.addAttribute("resource", resource); return "configuration" // maps to my jsp; }
如果资源是地图,则使用 request.setAttribute("resource", resource)
request.setAttribute("resource", resource)
<c:forEach var="entry" items="${resource}"> <tr> <td>${entry.key}</td> <td><input type = "text" name = "${entry.key}" value = "${entry.value}"></td> </tr> </c:forEach>