I understand that there is no mapping for the "dispatcher" servlet, but how and where to add it to the project without using web.xml, (everything is annotated)? Or am I misunderstanding something?

<link href="${pageContext.request.contextPath}css/bootstrap.css" rel="stylesheet"> 

WebAppConfig:

 @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/pages/**").addResourceLocations("/pages/"); } @Bean public UrlBasedViewResolver urlBasedViewResolver(){ UrlBasedViewResolver resolver = new UrlBasedViewResolver(); resolver.setPrefix("/pages/"); resolver.setSuffix(".jsp"); resolver.setViewClass(JstlView.class); return resolver; } 

and accordingly:

 WARNING: No mapping found for HTTP request with URI [/css/bootstrap.css] in DispatcherServlet with name 'dispatcher' окт 02, 2016 9:35:39 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI [/css/style.css] in DispatcherServlet with name 'dispatcher' окт 02, 2016 9:35:39 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI [/css/font-awesome.css] in DispatcherServlet with name 'dispatcher' 
  • Where do you keep the bootstrap.css resources in the project? Write the full path. - MrFylypenko
  • @MrFylypenko src / main / resources / webapp / css - JVic
  • one
    registry.addResourceHandler("/pages/**") indicates that requests should be: <link href="${pageContext.request.contextPath}pages/css/bootstrap.css" rel="stylesheet"> , and addResourceLocations("/pages/") indicates the location of resources, in this case src/main/resources/webapp/pages/css - MrFylypenko
  • @MrFylypenko Thank you very much! Please register as an answer, I mark as true! - JVic

1 answer 1

Your code does not have the correct addressing for getting resources.

 registry.addResourceHandler("/pages/**") 

indicates that the connected resources should be such:

 <link href="${pageContext.request.contextPath}pages/css/bootstrap.‌​css" rel="stylesheet"> 

and the parameter

 addResourceLocations("/pages/") 

points to the location of resources in the webapp directory:

 src/main/resources/webapp/pages/css