How to configure in spring bean annotation?

I am starting a new project with spring 4 and I am confusing how I can map my i18n file:

In spring 3 I was using xml configuration like this:

<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver" />
<bean id="messageSource" class="">
    <property name="basenames" value="messages" />
<bean id="i18n" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="locations">
    <property name="ignoreResourceNotFound" value="true" />

And in my jsps files I access it by:

<spring:message code="any key" />

In spring 4 I am avoiding to use xml configuration.. I tried the following:

public ResourceBundleMessageSource messageSource() throws Exception {
    ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
    return resourceBundleMessageSource;

public PropertiesFactoryBean propertiesFactoryBean() throws Exception {
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    Resource resource = new ClassPathResource("");
    return propertiesFactoryBean;

That class is annotated with @Configuration, but apparently is missing anything..

When I try to access index.jsp, I receive the following exception:

org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspTagException: No message found under code 'application.title' for locale 'pt_BR'.

Any help is appreciated.




<spring:message code="myMessage"/> with <fmt:message key="myMessage"/>

and on web.xml


dont forget to add fmt taglib

Need Your Help

How to generate hex sequence in Swift?

swift hex

Hey guys I am trying to create a tool to calculate how many 6 bytes sequence it generates within a certain time set by me, like 10s or 1min and so on. The sequence, for example, is: 4F B0 33 47 A3 ... mvc another controller in the same folder

javascript controller

I have a folder 'Report' which holds ReportController.