Skip to content

springUrl Velocity macro should encode the given URI using the response [SPR-14027] #18599

@spring-projects-issues

Description

@spring-projects-issues

Brian Clozel opened SPR-14027 and commented

Spring provides ways to rewrite resource URLs using the ResourceUrlEncodingFilter and ResourceUrlProvider. By using the HttpServletResponse.encodeUrl method, supported template engines can trigger that mechanism to rewrite the resource URL.

The dedicated Velocity macros provided by Spring, springUrl only prepends the URL with the context, instead of calling the actual method RequestContext.getContextUrl; this is actually done for the Freemarker equivalent.

In the meantime, developers who want this feature should override Spring's macro or declare their own like this:

#macro( springResourceUrl $relativeUrl )$springMacroRequestContext.getContextUrl(${relativeUrl})#end

Affects: 4.2.5

Reference URL: http://stackoverflow.com/questions/35844482/how-to-use-spring-resourceurlencodingfilter-with-velocity-template

Issue Links:

Referenced from: commits 0a56667, f76b38c

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions