0

I am using @RequestMapping("/**") but it does not load all the web related files like js, css etc.

@ControllerAdvice    public class ServiceExceptionHandler extends ResponseEntityExceptionHandler {@RequestMapping("/**")  public ModelAndView fallbackHandler(HttpServletRequest request, HttpServletResponse response) throws Exception {
return new ModelAndView("xxx/errors");

}

user3334226
  • 151
  • 1
  • 5
  • 15

1 Answers1

1

You need to make sure to have your directory containing those items set as permitAll. Request mapping has nothing to do with it. Since you are using spring-boot add something like this to your spring-security configuration:

http.authorizeRequests().antMatchers("/css/**", "/js/**", "/images/**").permitAll();
Martin Čuka
  • 16,134
  • 4
  • 23
  • 49
  • When I use @RequestMapping(" * "), everything gets loaded. Only when I change to @RequestMapping(" /** "), it does not load any file. http.authorizeRequests(). is already there for all the resources. – user3334226 Apr 26 '17 at 21:12
  • please can you edit your question and show me your pom.xml ? – Martin Čuka Apr 26 '17 at 21:19
  • can you specify which entry are you looking for in pom.xml? – user3334226 Apr 26 '17 at 21:25
  • Did you check this http://stackoverflow.com/questions/24661289/spring-boot-not-serving-static-content there are several answers which can help you. Also keep in mind By default Spring Boot will serve static content from a folder called /static (or /public or /resources or /META-INF/resources) in the classpath or from the root of the ServletContext. – Martin Čuka Apr 26 '17 at 21:25
  • I was curious what did you set up. You know spring-boot is magic and all configuration is done behind the scene when you add dependency to your project... – Martin Čuka Apr 26 '17 at 21:27
  • all my static content are under /resources folder. I am not able to include pom.xml as it tells me my question is mostly code and need to add more information. – user3334226 Apr 27 '17 at 13:22
  • well, it's impossible to help you when you give us so little information about your project. The most common error is people forget to permit static content in spring security which is not your case. From the snippet of code you provided I can't help your more. There's definetly something wrong with your configuration – Martin Čuka Apr 27 '17 at 14:40