开发者

How to use <spring:message> inside an attribute of <form:input>?

I have JSP code like:

<div class="formRow">
    <form:input id="email_email" name="email_email" title="XXXXX"/>" path="email" cssClass="input required email" />
    <form:errors path="email" cssClass="error" />
</div>

I want to set the title attribute with some tooltip text, supporting i18n. How would I do this?

I am looking to do something like this:

<div class="formRow">
    <form:input id="email_emai开发者_Python百科l" name="email_email" title="<spring:message code="tooltip.text" />"/>" path="email" cssClass="input required email" />
    <form:errors path="email" cssClass="error" />
</div>


<spring:message code="tooltip.text" var="variable1"/>
<form:input id="email_email" name="email_email" title="${variable1}" path="email" 
                      cssClass="input required email" />

You can't use a tag inside an attribute: But you can use the above. It works fine.


You can't use a tag inside a tag, simply. You can do something like this,

<spring:message code="tooltip.text" var="i18nTooltip"/> 
<form:input id="email_email" name="email_email" title="${i18nTooltip}" path="email" 
                      cssClass="input required email" />

P.S. Better use ${i18nTooltip}, instead of, i18nTooltip, to avoid confusion.


I think this is the most cleaner way to do it :

 <form:input id="email_email" name="email_email" title='<spring:message code="tooltip.text"/>' path="email" cssClass="input required email" />

Look for the changed code being, I have removed double qoutes of title attribut to single qoutes and its works wonders.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜