zoukankan      html  css  js  c++  java
  • spring mvc 资源包的映射

    在springmvc.xml中进行设置;

    <?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:mvc="http://www.springframework.org/schema/mvc"
        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.1.xsd
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-4.1.xsd">
        ...
        <!-- 进行资源的映射 -->
        <mvc:resources location="/resources/" mapping="/resources/**" />
        ...
    
    
    </beans>

     在web.xml中的设置;

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        id="WebApp_ID" version="3.0">
        <servlet>
            <servlet-name>user</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/springmvc.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>user</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
    
        <!-- 解决工程编码过滤器 -->
        <filter>
            <filter-name>characterEncodingFilter</filter-name>
            <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>UTF-8</param-value>
            </init-param>
        </filter>
    
        <filter-mapping>
            <filter-name>characterEncodingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    </web-app>
  • 相关阅读:
    程序员跳槽到对手公司,被前老板设计陷害
    创业码农被公司套路最惨的一次经历
    记录一次由屁股决定研发的狗血经历
    不去培训班,你凭什么觉得自己能学会编程,嗯?!
    毕业生是怎么一步步给培训班骗去学编程的
    我的一次被骗去培训班狗血的经历
    不去培训班,你凭什么觉得自己能学会编程
    Phabricatori 之项目管理软件
    kvm之virt-manage 管理功能
    debian 10 安装apache 和php
  • 原文地址:https://www.cnblogs.com/stono/p/4514024.html
Copyright © 2011-2022 走看看