Category «Spring»

How to read properties file in Spring.

If you need to read properties file in your Spring application all you need is to configure a PropertyPlaceholderConfigurer bean in your application context. Following example shows how to read property values from a properties file named config.properties. This file needs to be in your classpath so Spring can find it. Let’s begin by creating …

How to configure multiple handlers in a Spring MVC web application

In Spring MVC, DispatcherServlet relies on handler mapping to determine which controller the request should be sent to. All handler mapping classes in Spring implement org.springframework.web.servlet.HandlerMapping interface. Spring distribution contains following four implementation of HandlerMapping interface. BeanNameUrlHandlerMapping SimpleUrlHandlerMapping ControllerClassNameHandlerMappign CommonsPathMapHandlerMapping BeanNameUrlHandlerMapping is the simplest of all and DispatcherServlet looks for this mapping by default. You …