Adding css ResourceHandlers in Spring


CSS to be added to the Spring 4 JSPs


  1. Create folder called resources\theme1\css under webapp. (I use maven project)
    Adding css ResourceHandlers in Spring.PNG
  2. Create main.css under css folder
  3. Add the resource handler in the Application context config
@ComponentScan(basePackages = { "org.grassfield.gaja" })
public class ApplicationContextConfig extends WebMvcConfigurerAdapter {
    @Bean(name = "viewResolver")
    public InternalResourceViewResolver getViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        System.out.println("---> returning viewResolver");
        return viewResolver;
    public void addResourceHandlers(final ResourceHandlerRegistry registry) {
        System.out.println("---> returning resourcehandlers");




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s