Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring 3 - Accessing messages.properties in jsp

I am new using spring 3 and have been stuck for a while on this.

Do you know how can I access messages.properties from a jsp. For instance, in the controller I set a value to my model:

model.setError("user.not.found")

messages.properties:

user.not.found=Sorry, we haven't been able to found this user

and in the jsp I want to be able to do

${model.error}

and displaying "sorry...". However I always get "user.not.found" even if this works fine when I use the @Valid ..., bindingResult and then in the form.

Thanks,

like image 650
tsunade21 Avatar asked Feb 01 '11 15:02

tsunade21


1 Answers

Use <spring:message> from the spring taglib:

<spring:message code = "${model.error}" />

where taglib is imported as

<%@ taglib prefix = "spring" uri = "http://www.springframework.org/tags" %>
like image 164
axtavt Avatar answered Oct 23 '22 09:10

axtavt