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");

}

1 Answer 1

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();
Sign up to request clarification or add additional context in comments.

7 Comments

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.
please can you edit your question and show me your pom.xml ?
can you specify which entry are you looking for in pom.xml?
Did you check this stackoverflow.com/questions/24661289/… 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.
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...
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.