zoukankan      html  css  js  c++  java
  • Spring配置静态目录

    mvc-dispatcher-servlet.xml文件

    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           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.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
        <!-- Load static resources -->
        <mvc:resources mapping="/javascript/**" location="/WEB-INF/pages/res/js/"/>
        <mvc:resources mapping="/styles/**" location="/WEB-INF/pages/res/css/"/>
        <mvc:resources mapping="/images/**" location="/WEB-INF/pages/res/images/"/>
        <!--If use Annotation must use it -->
        <mvc:annotation-driven/>
    
    
        <context:component-scan base-package="com.springapp.mvc"/>
        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="/WEB-INF/pages/"/>
            <property name="suffix" value=".jsp"/>
        </bean>
    
    
    </beans>

    locatiom值为项目的资源路径,mapping值为项目的引用资源路径

    web.xml

    <web-app version="2.4"
        xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
        http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    
        <display-name>Spring MVC Application</display-name>
    
        <servlet>
            <servlet-name>mvc-dispatcher</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>mvc-dispatcher</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
    </web-app>

  • 相关阅读:
    npm ERR! code EINTEGRITY npm! ERR! shal-
    Python 的类的下划线命名有什么不同?
    Linux下通过源码编译安装程序
    Mac OSX下Sublime Text配置使用Ctags实现代码跳转
    Python基础-*args和**kwargs魔法变量
    alpha版、beta版、rc版的意思
    英特尔第四代酷睿处理器数字和字母代表什么意思
    笔记本CPU低压和标压有什么区别?
    MySQL通过localhost无法连接数据库的解决
    sudo:无法解析主机 解决方案
  • 原文地址:https://www.cnblogs.com/Jsonlu/p/4845696.html
Copyright © 2011-2022 走看看