I am using Spring 3.0 and working with the spring security for login. I have placed the login.jsp page in the webapp folder and I am trying to use messages for localization support e.g.:
<spring:message code="label.title"/>
Unfortunately, the jsp cannot find the message giving error:
javax.servlet.ServletException: javax.servlet.jsp.JspTagException: No message found under code 'label.title' for locale 'en_US'
When I use the message code in a jsp that goes through a controller, it works fine.
Since the spring security redirects to the login.jsp page when user is not logged in, the page is processed without a controller (directly).
Anyone knows how to make the jsp see the resource bundle also when not going through a controller?
Thanks!
You have to force Spring to render the page login.jsp, which is actually not managed by Spring. So, create a dummy controller:
/**
* UI Controller that renders the signin-form.
*/
@Controller
public class SigninController {
/**
* Render the signin form to the person as HTML in their web browser.
* Returns void and relies in request-to-view-name translation to kick-in to
* resolve the view template to render.
*/
@RequestMapping(value = "/login", method = RequestMethod.GET)
public void login() {
}
}
and create the view named "login" depending of your used ViewResolver (TilesViewResolver, UrlBasedViewResolver...)