简体   繁体   中英

Using spring:message tag inside of form:input tag in Spring MVC

I want to Internationalize the content of an attribute in my Spring MVC app, the snippet code from my JSP file :

<form:input type="text" path="someAttribute" title="something"/>

And it's working fine, But When I want to Internationalize like this :

<form:input type="text" path="someAttribute" 
title="<spring:message code="label.something"/>"/>

it seems wrong, since it throws a org.apache.jasper.JasperException Exception. My question Is : How Can I internationalize the "Something" String inside of the title attribute in my form:input Tag ?

You can use JSTL tags

<c:set var="title"><spring:message code="label.something"/></c:set>
<form:input type="text" path="someAttribute" title="${title}"/>

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