【发布时间】:2017-05-23 18:00:36
【问题描述】:
我有一个 Spring 项目,其中我将以下 webjar 包含到 pom.xml 中:
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.7-1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.1.1</version>
</dependency>
然后我在我的 HTML 视图中包含以下链接和脚本:
<link rel="stylesheet" href="@{/webjars/bootstrap/3.3.7-1/css/bootstrap.min.css}" />
<script src="@{/webjars/jquery/3.1.1/jquery.min.js}"></script>
<script src="@{/webjars/bootstrap/3.3.7-1/js/bootstrap.min.js}"></script>
但它不起作用,没有找到映射:
[org.springframework.web.servlet.PageNotFound] (default task-15) No mapping found for HTTP request with URI [/TestPublicWeb-0.0.1-SNAPSHOT/webjars/bootstrap/3.3.7-1/css/bootstrap.min.css] in DispatcherServlet with name 'testapp'
...所以我尝试在servlet.xml 中包含以下映射:
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
但是有了这个,我的/TestApplication 的映射就找不到了:
[org.springframework.web.servlet.PageNotFound] (default task-13) No mapping found for HTTP request with URI [/TestApplication/] in DispatcherServlet with name 'testapp'
webjars应该如何以正确的方式包含在Spring项目中?
【问题讨论】:
标签: java jquery twitter-bootstrap spring-mvc thymeleaf