Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7055757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:47:13+00:00 2026-05-28T03:47:13+00:00

I am trying to configure Spring MVC programmatically instead of xml files. Almost everything

  • 0

I am trying to configure Spring MVC programmatically instead of xml files. Almost everything is working fine, but I am having troubles with the ResourceBundleMessageSource declaration.

My configuration class looks like this:

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "xx.xx.xx.spring.controller")

public class MvcConfig {

    @Bean
    public ResourceBundleMessageSource configureResourceBundleMessageSource() {
        ResourceBundleMessageSource resource = new ResourceBundleMessageSource();
        resource.setBasename("messages");
        return resource;
    }

    @Bean
    public UrlBasedViewResolver configureUrlBasedViewResolver() {
        UrlBasedViewResolver resolver = new UrlBasedViewResolver();
        resolver.setPrefix("/WEB-INF/jsp/");
        resolver.setSuffix(".jsp");
        resolver.setViewClass(
            org.springframework.web.servlet.view.JstlView.class);
        return resolver;
    }
}

And my initializer like this:

public class Initializer implements WebApplicationInitializer {

    public void onStartup(ServletContext servletContext) 
            throws ServletException {

        AnnotationConfigWebApplicationContext mvcContext = 
            new AnnotationConfigWebApplicationContext();
        mvcContext.register(MvcConfig.class);
        mvcContext.setServletContext(servletContext);
        mvcContext.refresh();
        ServletRegistration.Dynamic menu = servletContext.addServlet("menu", 
            new DispatcherServlet(mvcContext));
        menu.setLoadOnStartup(1);
        menu.addMapping("*.html");
    }
}

The application is working, but it is not showing the messages from messages.properties that is located in /WEB-INF/classes/messages.properties. And if I use xml files it works fine too.

In the JSP I have the following line±

<fmt:message key="heading"/>

And it is displayed like ???heading??? in the browser.

I dont know if it is a problem with the path or I need to put more params.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:47:14+00:00Added an answer on May 28, 2026 at 3:47 am

    and finally It’s working! The problem was in the method name. If you want to create a bean with a id, the id of the bean is the name of the method. So i have changed the name of the method (configureResourceBundleMessageSource()) to messageSource().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use hibernate with spring 3 mvc but at the moment I
Trying to configure spring 3 MVC, here is what I did so far: I
I'm trying to configure ASP.NET MVC 2 RC and Spring .NET 1.3 to use
I'm trying to configure a Spring config (xml) file and am trying to add
I'm trying to learn Spring MVC basics and having issues with the way URL
I'm trying to configure a class with Annotation based configuration in Spring 3, which
I trying spring 3 mvc this package is org.spring.test and code is @Controller @RequestMapping(/welcome)
We are trying to configure Spring JavaMailSender to work with Amazon's SES service using
I'm trying to write a web application using Spring MVC. I have a configuration
I am trying to configure Spring Security in my simple application. Here is my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.