我正在尝试通过依赖 webjars 添加 bootstrap 和 jquery
我在我的 JSP 中添加了以下行:
<link rel='stylesheet' href='/webjars/bootstrap/3.3.5/css/bootstrap.min.css'>
<script type="text/javascript" src="/webjars/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/webjars/jquery/2.1.4/jquery.min.js"></script>
我的 spring-dispatcher-servlet.xml 看起来像:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
<context:component-scan base-package="com.meltum.*" />
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles-def.xml</value>
</list>
</property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView"/>
</bean>
当我删除我的 XML 中的 mvc:resources 行时,页面正在工作,否则我得到一个 404 页面。有人对我的问题有想法吗?