Spring静态资源servlet请求

Spring静态资源servlet请求,spring,servlets,Spring,Servlets,我的英语不好。请理解 我负责维护一个用Spring、tiles和ibatis框架构建的网站 问题是所有的gif、js等等。。。查看DispatcherServlet,因为大多数静态资源的地址类似于/home/images/hbg_01.gif。资源路径由homeServlet映射 但是我希望我的静态资源被任何用Web.xml编写的DispatcherServlet忽略 我是J2EE新手。所以如果是因为缺乏信息。请留下评论。如果需要,我会给你任何东西 这是我的web.xml <?xml ve

我的英语不好。请理解

我负责维护一个用Spring、tiles和ibatis框架构建的网站

问题是所有的gif、js等等。。。查看DispatcherServlet,因为大多数静态资源的地址类似于/home/images/hbg_01.gif。资源路径由homeServlet映射

但是我希望我的静态资源被任何用Web.xml编写的DispatcherServlet忽略

我是J2EE新手。所以如果是因为缺乏信息。请留下评论。如果需要,我会给你任何东西

这是我的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0" metadata-complete="true">

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/xml/root-context.xml
            /WEB-INF/xml/security.xml
        </param-value>
    </context-param>


    <!-- Processes application requests -->
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/xml/appServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/app/*</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>adminServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/xml/adminServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>adminServlet</servlet-name>
        <url-pattern>/admin/*</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>homeServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/xml/homeServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>homeServlet</servlet-name>
        <url-pattern>/home/*</url-pattern>
    </servlet-mapping>


    <servlet>
        <servlet-name>monitorServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/xml/monitorServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>monitorServlet</servlet-name>
        <url-pattern>/monitor/*</url-pattern>
    </servlet-mapping>


    <servlet>
        <servlet-name>monitorDemoServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/xml/monitorDemoServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>monitorDemoServlet</servlet-name>
        <url-pattern>/monitor_demo/*</url-pattern>
    </servlet-mapping>


    <servlet>
        <servlet-name>projectServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/xml/projectServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>projectServlet</servlet-name>
        <url-pattern>/project/*</url-pattern>
    </servlet-mapping>


    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/log4j.properties</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>


    <filter>
        <description></description>
        <display-name>encodingFilter</display-name>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>EUC-KR</param-value>
        </init-param>
       <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
       </init-param>
    </filter>

    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>



    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/home/*</url-pattern>
        <url-pattern>/project/*</url-pattern>
        <url-pattern>/admin/*</url-pattern>
        <url-pattern>/monitor/*</url-pattern>
        <url-pattern>/monitor_demo/*</url-pattern>
    </filter-mapping>

    <session-config>
        <session-timeout>180</session-timeout>
    </session-config>

</web-app>

上下文配置位置
/WEB-INF/xml/root-context.xml
/WEB-INF/xml/security.xml
appServlet
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/xml/appServlet/servlet-context.xml
1.
appServlet
/应用程序/*
adminServlet
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/xml/adminServlet/servlet-context.xml
1.
adminServlet
/管理员/*
家庭小旅馆
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/xml/homeServlet/servlet-context.xml
1.
家庭小旅馆
/家/*
监视器servlet
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/xml/monitorServlet/servlet-context.xml
1.
监视器servlet
/监视器/*
monitorDemoServlet
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/xml/monitorDemoServlet/servlet-context.xml
1.
monitorDemoServlet
/监视器演示/*
projectServlet
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/xml/projectServlet/servlet-context.xml
1.
projectServlet
/计划/*
log4jConfigLocation
/WEB-INF/log4j.properties
org.springframework.web.util.Log4jConfigListener
org.springframework.web.context.ContextLoaderListener
编码滤波器
编码滤波器
org.springframework.web.filter.CharacterEncodingFilter
编码
EUC-KR
强制编码
真的
编码滤波器
/*
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/家/*
/计划/*
/管理员/*
/监视器/*
/监视器演示/*
180

mvc静态资源可能会有所帮助。Pl.参考:


正如您所说的
/home/images/hbg_01.gif
。资源路径由
homeServlet
映射

更改url模式
/home/*
,以避免映射到
homeServlet
,例如:

<servlet-mapping>
    <servlet-name>homeServlet</servlet-name>
    <url-pattern>/home/anything/*</url-pattern>
</servlet-mapping>

家庭小旅馆
/家/任何东西/*