<s:textfield> struts2 </s:textfield>中的属性值

时间:2011-03-31 06:32:54

标签: struts2

如何在<s:textfield>

中设置属性值

我试过了<s:textfield name="customerName" label="Customer Name" value='<s:property value="userInfo.customerName"' />,但它没有用。

请帮忙

3 个答案:

答案 0 :(得分:17)

您不能在标签内使用标签。改为使用OGNL!

<s:textfield name = "customerName" 
            label = "Customer Name" 
            value = "%{userInfo.customerName}"/>

答案 1 :(得分:0)

使用OGNL(对象图形导航语言)在任何类型的struts字段中获取值。如果你没有得到价值,请检查变量的setter和getter。

<s:textfield name="transValueChange" id="transValueChange" 
             value ="%{transValue}" theme="simple" maxLength="30"
             onkeypress="return isNumberKey(event)">
</s:textfield>

OR

<s:select name="propCode" id="propCode" list="propClassMasMap" theme="simple"
          value="%{propCode}" onchange="" cssClass="text">
</s:select>

答案 2 :(得分:0)

我用过这个:

<table>
    <s:label>User Name:</s:label>
    <s:textfield name="user.userid" cssClass="tb5" type="text" placeholder="User Name" value="%{#session.userid}" disabled="true" /> 
</table>

disabled属性不是必需的,我用它来禁用文本字段,以便从数据库中检索值,并禁止用户对其进行更改。

相关问题