title: Spring boot static content for nested / prefixed controllers
body: <p>I'm using Spring boot 2.0.2 and Freemarker for my web application. The static content of my webapp fails to load for nested / prefixed controllers.</p>
  
  <p>All of the static content (images, CSS, js) is under</p>
  
  <pre><code>/src/main/resources/static/js
  /src/main/resources/static/images
  /src/main/resources/static/css
  </code></pre>
  
  <p>Everything works great if I use this controller:</p>
  
  <pre><code>@RequestMapping(value = "/userProfile", method = RequestMethod.GET)
  public ModelAndView getUser(@ModelAttribute("model") ModelAndView model,@RequestParam("userId") String userId) {
  
      UserProfile userProfile = userService.findById(userId);
      model.addObject("userProfile", userProfile);
      model.setViewName("userDetails");
      return model;
  }
  
    userDetails.ftl is located at /src/main/resources/templates/userDetails.ftl
  </code></pre>
  
  <p>However, I'm seeing 404 on the static content (js/css/images) for this controller while making a GET request from the browser.</p>
  
  <pre><code>https://localhost:8443/users/js/saveUser.js -- 404
  (Please note "users" in the URL while trying to load static content)
  
  @RequestMapping(value = "/user/profile", method = RequestMethod.GET)
  public ModelAndView getUser(@ModelAttribute("model") ModelAndView model,@RequestParam("userId") String userId) {
  
      UserProfile userProfile = userService.findById(userId);
      model.addObject("userProfile", userProfile);
      model.setViewName("userDetails");
      return model;
  }
  </code></pre>
  
  <p><strong>Code of the view</strong></p>
  
  <pre><code>&lt;link rel="stylesheet" type="text/css" href="css/homepage.css"&gt;
  &lt;link rel="stylesheet" type="text/css" href="css/user-profile-display.css"&gt;
  &lt;script type="text/javascript" src="js/saveUser.js}"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/authenticate.js}"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I've looked at the following issues but can't find a solution that would work:</p>
  
  <p><a href="https://stackoverflow.com/questions/28006501/how-to-specify-prefix-for-all-controllers-in-spring-boot">How to specify prefix for all controllers in Spring Boot?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/43940856/spring-boot-separate-rest-from-static-content">spring boot: separate REST from static content</a></p>
  
  <p>Any help would be appreciated.</p>