Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Erro ao importar arquivos CSS e JS no spring

Não estou conseguindo importar os arquivos css e js em um projeto spring mvc 4

WARN  [org.springframework.web.servlet.PageNotFound] (default task-56) No mapping found for HTTP request with URI [/Estoque04/resources/css/estilo.css] in DispatcherServlet with name 'dispatcher'

Spring.java

package sistema.estoque.springmvc.config;

import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

public class Spring extends AbstractAnnotationConfigDispatcherServletInitializer {

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return null;
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[] { App.class };
    }

    @Override
    protected String[] getServletMappings() {
        return new String[] { "/","/resources/css/" };
    }

}

App.java

package sistema.estoque.springmvc.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

import sistema.estoque.springmvc.controller.IndexController;

@EnableWebMvc
@ComponentScan(basePackageClasses = { IndexController.class })
public class App {

    @Bean
    public InternalResourceViewResolver resolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("/WEB-INF/views/");
        resolver.setSuffix(".jsp");
        return resolver;
    }
}
1 resposta
solução!
@Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }