spring mvc 配置對靜態資源的訪問

在spring mvc的配置文件中作以下配置:css

一、web

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
    <context:component-scan base-package="com.vrvwh.wh01.controller">
    </context:component-scan>
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value=""></property>
        <property name="suffix" value=".jsp"></property>
    </bean>
<mvc:annotation-driven /><!-- 默認的註解映射的支持 -->
  <!---->
<mvc:default-servlet-handler />對靜態資源文件的訪問
</beans>

 

一、spring

<mvc:default-servlet-handler />

<!-- 這樣根目錄下面的resource的文件(.css,.js等)就不會被spring的DispatchServlet進行過濾 -->  spring-mvc

2.    <mvc:resources location="/resources/" mapping="/resources/**"/>  mvc

相關文章
相關標籤/搜索