Skip to content

use RestUrlRewriteFilter to rewrite url from "/foo.gif" to "/static/foo.gif" for visit static resource [SPR-6134] #10802

@spring-projects-issues

Description

@spring-projects-issues

badqiu opened SPR-6134 and commented

current petclinic sample to visit static resource must start with /static prefix.

However, we can use URL rewriting to avoid adding the prefix.

RestUrlRewriteFilter will forward like /foo.js => /static/foo.js
rewrite usecase:
/foo.js => /static/foo.js
/foo/demo.gif => /static/demo.gif

not rewrite by excludeExtentions, default value is do,jsp,jspx:
/foo.jsp => /foo.jsp
/foo.jspx => /foo.jsp
/foo.do => /foo.do

web.xml config
<filter>
<filter-name>RestUrlRewriteFilter</filter-name>
<filter-class>cn.org.rapid_framework.web.filter.RestUrlRewriteFilter</filter-class>
<init-param>
<param-name>prefix</param-name>
<param-value>/static</param-value>
</init-param>
<init-param>
<param-name>excludeExtentions</param-name>
<param-value>jsp,jspx,do</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>RestUrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

this is my patch.


Affects: 3.0 M4

Attachments:

Issue Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issuetype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions