Skip to content

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

Closed

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:

Activity

  1. spring-projects-issues commented on Sep 19, 2009

    @spring-projects-issues
    CollaboratorAuthor

    badqiu commented

    this is my path file

  2. spring-projects-issues commented on Sep 25, 2009

    @spring-projects-issues
    CollaboratorAuthor

    badqiu commented

    now, add excludePrefixes property for RestUrlRewriteFilter

     <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>excludePrefixes</param-name>
              <param-value>/scripts,/images,/styles</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>
  3. added
    type: enhancement
    status: duplicate
    in: web
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webstatus: duplicatetype: enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions