Thymeleaf local urls not working

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Thymeleaf local urls not working

Rakshit Vashishta
Whenever I use the @{} operator, it works only with absolute web urls, but when I try replacing them with local jar references, they don't work. I even checked the network tab on the browser and they all load correctly. I face this issue with th:href as well as th:src. Here is some of the code:

<!DOCTYPE html>
<html xmlns:th="">

<head th:fragment="common-header">
    <title>Fullstack app skeleton</title>
    <link th:href="@{/webjars/bootstrap/3.3.6/css/bootstrap.min.css}"

    <link type="text/css" th:href="@{/css/styles.css}" rel="stylesheet"> </link>

<div th:fragment="before-body-scripts">
        <script th:src="@{/webjars/jquery/2.1.4/jquery.min.js}"></script>          <script th:src="@{/webjars/bootstrap/3.3.6/js/bootstrap.min.js}"></script>        <script th:src="@{/js/fullstackapp.js}"></script></div>

None of the @{} urls work.
Reply | Threaded
Open this post in threaded view

Re: Thymeleaf local urls not working

works like a charm in my projects...

Be sure that u have in your config-file something like:
public void addResourceHandlers(ResourceHandlerRegistry registry) {

<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/> 
in xml-config