I have file index.html that looks like this:
<head>
...
<link rel="stylesheet" type="text/css" th:href="@{/css/index.css}"/>
<script th:src="@{/js/app.js}" type="script" async></script>
...
</head>
which is rendered like:
<link rel="stylesheet" type="text/css" href="/css/index.css">
<script src="/js/app.js" type="script" async="">
and file structure like this:
when visiting /index
in browser, styles work but javascript is not loaded.
I have tried different filenames, accessing /css/index.css
and /js/app.js
in browser (works), adding following code (didn’t change behavior):
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/css/**", "/js/**")
.addResourceLocations("classpath:/static/css/", "classpath:/static/js/");
}
Also, in browser network tab, I see that web page is loading index.css, but not app.js.