Make sure you are packaging your project as a war
in your pom.xml
.
The /src/main/resources
folder is usually deployed to WEB-INF/classes
, so it won't be accessible directly from the context.
However, The /src/main/webapp
is normally deployed to /
(root of your web app), which is accessible from the context.
You should put your web resources under /src/main/webapp
(e.g. /src/main/webapp/css
). These are then automatically deployed under the context root of your web application. They are then accessible from e.g. /css
.
<link rel="stylesheet" th:href="@{/css/main.css}" />
I'd also move your templates to /src/main/webapp/WEB-INF/templates
.