0

次の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}が正しく評価されていません。サーブレット()からリクエストパラメータとして入力を取得しようとすると、中かっこなしでrequest.getParameter(StringKey)リテラルを取得します。$keyすると、ELrequest.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;
    } 
4

1 に答える 1

1

リソースがマップの場合、を使用して設定されます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>
于 2012-11-20T20:17:51.560 に答える