Using Spring 2.6.4, I have this method which returns a page:
@GetMapping("/items/{id}")
public String itemPage(Model model, @PathVariable long id) {
model.addAttribute("item",items.getItem(id));
return "itemPage"; //"itemPage" is a template
}
Given a template (itemPage.html) which loads resources from /assets, located at ../static:
(...)
<script src="assets/js/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/bs-init.js"></script>
(...)
When invoking this method, the browser 'thinks' assets are located at /items/assets, where 'items' is just part of the mapping but not a real directory, making that:
Instead of requesting just for the resources located at '/assets'. Hence, the browser is not loading properly the assets.
Comment From: bclozel
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.