2

你好朋友我正在尝试将解密值表达式写入 s:textfield value"<%=custFirstName%>" 类似的东西,但它给了我一个错误,即根据标记文件中的 TLD 或属性指令,属性值不接受任何表达式那么在 . 请帮帮我。在输入类型它工作得很好,但我想通过struts tage做同样的事情。

这是我的代码

    <s:iterator value="userList">
        <s:set var="custFirstName" value="custFirstname"/>
        <s:set var="custLastName" value="custLastname"/>
        <s:set var="custEmail" value="custEmail"/>
        <s:set var="custPhone" value="custPhone"/>
        <s:set name="custVerified" value="custIsVerified"/>
        <%
        String custFirstName = pageContext.getAttribute("custFirstName").toString();
        String custLastName = pageContext.getAttribute("custLastName").toString();
        String custEmail = pageContext.getAttribute("custEmail").toString();
        String custPhone = pageContext.getAttribute("custPhone").toString();

        Encryption encryption=new Encryption();
        custFirstName = Encryption.decString(custFirstName);
        custLastName = Encryption.decString(custLastName);
        custEmail = Encryption.decString(custEmail);
        custPhone = Encryption.decString(custPhone);
    %>




            <td> <s:textfield value="<%=custFirstName%>" label="First Name"/></td>
            <%-- <input type="text" value="<%=custFirstName%>" > --%>
            <td> <s:textfield name="custLastName" label="Last Name"/></td>
            <td> <s:textfield name="custEmail" label="Email"/></td>
            <td> <s:textfield name="custPhone" label="phone"/></td>
            <td> <s:textfield name="custCountry" label="Country"/></td>
            <td> <s:textfield name="custState" label="State"/></td>
            <td> <s:textfield name="custCity" label="City"/></td>
            <s:submit value="Update"></s:submit>

    </s:iterator>   

</s:form>



<input type="text "value="<%=custFirstName%>">

我想将上面的输入值表达式写入 s:textfield value="" 我该怎么做。

4

2 回答 2

0

您需要设置 value 属性,没错,但它应该是 OGNL 表达式。

Encryption encryption=new Encryption();
custFirstName = Encryption.decString(custFirstName);
custLastName = Encryption.decString(custLastName);
custEmail = Encryption.decString(custEmail);
custPhone = Encryption.decString(custPhone);
ValueStack vs = ActionContext.getContext().getValueStack();
vs.set("custFirstName", custFirstName);
vs.set("custLastName", custLastName);
vs.set("custEmail", custEmail);
vs.set("custPhone", custPhone);

然后你可以使用OGNL

<s:textfield name="custFirstName" value="%{#custFirstName}" label="First Name"/>

...

您可能还会查看此Struts 2 Value Stack/OGNL

于 2014-12-24T09:37:48.070 回答
0

你可以使用类似的东西:

<td> <s:textfield value="%{#custFirstName}" label="First Name"/></td>
于 2014-12-24T08:38:09.397 回答