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>
  • 相关阅读:
    debug
    whlie and for
    while and for 2
    用鸿蒙开发AI应用(七)触摸屏控制LED
    animation动画组件在鸿蒙中的应用&鸿蒙的定时函数和js的动画效果
    2020技术征文大赛获奖名单公示
    HarmonyOS三方件开发指南(8)——RoundedImage
    从微信小程序到鸿蒙js开发【02】——数据绑定&tabBar&swiper
    从微信小程序到鸿蒙js开发【01】——环境搭建&flex布局
    HarmonyOS三方件开发指南(7)——compress组件
  • 原文地址:https://www.cnblogs.com/stono/p/4514024.html
Copyright © 2011-2022 走看看