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

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


<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.