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>

  • 相关阅读:
    条款04:确定对象在使用前已经被初始化
    条款06:若不想使用编译器自动生成的函数,就应该明确拒绝
    计算机操作系统之死锁的原因和必要条件
    条款10:令operator=返回一个reference to *this
    条款02:尽量以const,enum,inline代替#define
    条款11:在operator=处理自我赋值
    计算机操作系统之进程与线程
    堆排序
    NodeJS For Windows
    我常用的linux命令
  • 原文地址:https://www.cnblogs.com/Jsonlu/p/4845696.html
Copyright © 2011-2022 走看看