简体   繁体   中英

Spring - how to exclude a particular URL from spring Controller?

May be this question has an answer already.But that is an accepted answer.Because it works in web servers only.

My web.xml will be ,

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

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>

I want to exclude the hello.html from the spring controller.

Also that thing should be work on all servers like tomcat,Jboss,websphere etc..

Is it possible ?Hope I will get a good solution.

How about just creating a new server-mapping point that points to the default servlet before the spring mapping?

<servlet-mapping>
    <servlet-name>Default</servlet-name>
    <url-pattern>hello.html</url-pattern>
</servlet-mapping>

Should work for tomcat but possibly it will work for other servers as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM