简体   繁体   中英

How can I put a placeholder in a struts2 textfield tag?

I'm using struts2 tags and want to put a placeholder in a <s:textfield> tag like this:

<s:set name="email" value="getText('email')" />
...

<s:form action="Login">
    <s:textfield key="email" theme="simple" placeholder="%{email}" 
         cssClass="span3"/>
    ...
</s:form>

email is defined in global.properties as "Correo electrónico" .

My problem is that when I see the jsp page, instead of seeing the value of email I see %{email} .

I read that it was a bug of Struts2 solved in version 2.3.1 here: https://issues.apache.org/jira/browse/WW-3644 , but I'm using Struts2 2.3.4 and I keep having the same problem.

Anyone knows any solution to this problem or any other way for putting the placeholder in the textfield?

I had the same problem and I solved it like this:

<s:textfield name="user.email" placeholder="%{getText('settings.email')}" />

I needed up update both my Struts 2 and OGNL jars. My OGNL jar is ognl-3.0.5.jar .

您应该在堆栈命名空间中创建但未推送的变量使用#前缀:

<s:textfield placeholder="%{#email}" ... etc ... />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM