2015-10-27 151 views
0

我試圖通過依賴webjars
加引導和jQuery我加在我的JSP下面幾行:與webjar集成春季刊

<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> 

我的春天 - 調度 - 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> 

當我刪除MVC:在我的XML資源線的頁面被別的工作,我得到一個404頁。 有沒有人有我的問題的想法?

+0

是否使用一個Servlet 3兼容的容器? –

+0

@JamesWard我不知道這意味着什麼,但也許不是 –

+0

@JamesWard如果你正在談論關於javax servlet的依賴(我在google上看到它指的是這樣),我可以告訴你我對我的依賴項目 –

回答

0

我只是在我的春天 - 調度 - servlet.xml中 改變的版本從3.1到4.0,並把MVC:資源在結束和一個MVC:註解驅動後

我的彈簧調度員的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-4.0.xsd 
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd  
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> 

<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> 

<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/> 
<mvc:annotation-driven></mvc:annotation-driven>