Spring Thymeleaf本地@{}URL不工作

Spring Thymeleaf本地@{}URL不工作,spring,spring-boot,thymeleaf,Spring,Spring Boot,Thymeleaf,我在springboot中使用thymeleaf,我提到的所有带有本地url的链接都不起作用。我甚至检查了浏览器上的“网络”选项卡,所有css和js资源都正确加载,但不知何故没有效果。下面是一些代码: <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head th:fragment="common-header"> <title>Fullstack app skeleton&l

我在springboot中使用thymeleaf,我提到的所有带有本地url的链接都不起作用。我甚至检查了浏览器上的“网络”选项卡,所有css和js资源都正确加载,但不知何故没有效果。下面是一些代码:

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:fragment="common-header">
<title>Fullstack app skeleton</title>
<!-- Bootstrap core CSS -->
<link th:href="@{/webjars/bootstrap/3.3.6/css/bootstrap.min.css}"
      rel="stylesheet"></link>

<!-- Custom styles for this template -->
<link type="text/css" th:href="@{/css/styles.css}" rel="stylesheet"> 
</link>
</head>
<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>
</html>

Fullstack应用程序框架

此外,我还检查了pom.xml,所有依赖项都已正确加载。在上面的代码中,当我提到绝对url()时,所有的引导功能都可以工作,但是当我使用对本地jar的引用时,它就不能工作了。有人能提出一个可能的原因吗?

我正在使用一个
.java
文件来映射
Bootstrap
Jquery

@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/resources/bootstrap/**")
            .addResourceLocations("classpath:/META-INF/resources/webjars/bootstrap/4.0.0/");
        registry.addResourceHandler("/resources/jquery/**")
            .addResourceLocations("classpath:/META-INF/resources/webjars/jquery/3.0.0/");
    }
}
这是我的
html
代码:

<link th:href="@{/resources/bootstrap/css/bootstrap.min.css}" rel="stylesheet"/>
<script th:src="@{/resources/jquery/jquery.min.js}"></script>
<script th:src="@{/resources/bootstrap/js/bootstrap.js}"></script>


希望能对你有所帮助

你能发布你的控制器代码来获取这个模板和你的
pom.xml
?嘿,谢谢你指出这一点,结果是请求映射中的url被错误地删除了..现在一切都解决了..我的错了。