您好,我有一个表单输入按钮,如下所示:
<form:input path="creationUsr.lastName" type="text" name="creationUsr.lastName" id="creationUsr.lastName" class="login-text" placeholder="<spring:message code='tile.form.lastName'/>" value=""/>
这是我的 spring 上下文区域设置:
<mvc:interceptors>
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>
</mvc:interceptors>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
如果我把这个不合规范的标签:
<spring:message code='tile.form.lastName'/>
这个值是我应该的。
我有办法解决这个问题,但有点丑陋。我可以在不使用 spring 和常规的情况下恢复到正常形式 <input type="text" name="lastname">
而不是<form:input
..然后将表单序列化为 json 并使用 javascript 发布帖子。
我确信一定有办法用 spring mvc 来做到这一点。
最佳答案
不能在另一个 JSP 标记的属性内使用 JSP 标记。要执行您想要的操作,请将消息保存在页面范围属性中,并使用 EL 将消息传递到输入标记:
<spring:message code='tile.form.lastName' var="lastNameMessage"/>
<form:input path="creationUsr.lastName"
type="text"
name="creationUsr.lastName"
id="creationUsr.lastName"
class="login-text"
placeholder="${lastNameMessage}"
value=""/>
关于java - Spring 区域设置消息仅在 spring 内不起作用 :form tag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13251010/