Why use url rewrite filter in spring?

A Spring application that I use declares a Tuckey UrlReWrite Filter, and then sets the rewrite rule as follows:

<rule>
    <from>^/(.*)$</from>
    <to last="true">/app/$1</to>
</rule>

Why is this?

Could Spring be able to recognize requests that do not reach the URL /app/?

Otherwise, what is the advantage of this redirect?

+3
source share
1 answer

, , Spring MVC DispatcherServlet URL- , URL- . <url-pattern>/</url-pattern>, .

, :

<urlrewrite default-match-type="wildcard">
    <rule>
        <from>/staticContentHere/**</from>
        <to>/staticContentHere/$1</to>
    </rule>
    <rule>
        <from>/**</from>
        <to>/app/$1</to>
    </rule>    
</urlrewrite>

EDIT: , Spring 3.0.4 <mvc:resources />. DispatcherServlet /resources webapp, (. http://blog.springsource.com/2010/07/22/spring-mvc-3-showcase/).

+6

Source: https://habr.com/ru/post/1761340/


All Articles