1 year ago

#319933

test-img

Carel Sánchez

Extra directory added when retrieving assets

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 request at /items/assets/(...) instead of requesting just for the resources located at '/assets'. Hence, the browser is not loading properly the assets.
I think it's a bug, but maybe I'm doing something wrong

html

spring

mustache

0 Answers

Your Answer

Accepted video resources