tsu*_*e21 4 validation spring-mvc
我是新手使用弹簧3并且已经卡住了一段时间.
你知道如何从jsp访问messages.properties.例如,在控制器中我为我的模型设置了一个值:
model.setError("user.not.found")
Run Code Online (Sandbox Code Playgroud)
messages.properties:
user.not.found=Sorry, we haven't been able to found this user
Run Code Online (Sandbox Code Playgroud)
在jsp我希望能够做到
${model.error}
Run Code Online (Sandbox Code Playgroud)
并显示"抱歉......".但是,当我使用@Valid ...,bindingResult然后在表单中时,我总是得到"user.not.found",即使它工作正常.
谢谢,
axt*_*avt 13
使用<spring:message>
从spring
标签库:
<spring:message code = "${model.error}" />
Run Code Online (Sandbox Code Playgroud)
其中taglib作为导入的位置
<%@ taglib prefix = "spring" uri = "http://www.springframework.org/tags" %>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9806 次 |
最近记录: |