Announcement Announcement Module
Collapse
No announcement yet.
Url view controller and escaped characters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Url view controller and escaped characters

    Dear all,

    I'm trying to integrate a content management system with Tiles under Spring but am having problems with escaped characters in the request URL and mapping the consequent view to a tile definition. For example if I have a Tile definition with the name "My Page" and I request "/foo/bar/My%20Page.html" then the UrlFileNameViewController uses the My%20Page as the view name and hence the tile definition is not resolved (note that I can request "/foo/bar/My Page" but the browser quite rightly escapes the whitespace to %20). I realise that the tile definition name is a literal name and not a url but is there any way to unescape Url escaped characters before hitting the view resolver (or is there a view resolver that actually does this)?

    I can't believe this is not possible, and someone somewhere must have hit a similar problem. Overiding the url view controller with a custom controller seems a bit overkill/hacky for something so simple.

    I'm a bit of a newbie at Tiles and Spring so bear with me if the answer is in fact obvious (usual wood-for-the-trees effect!).

    Dumbdare

    p.s. searched the forums but only found one other relevant post that didn't really answer my question, hence new thread

  • #2
    use a custom view controller

    Ok, I've answered my own question, basically I extended the UrlFileNameViewController to get the uri string from a UrlPathHelper utility class. You have to first set a url decode switch on the helper before requesting the uri (!) which then automatically decodes the uri through the getRequestUri helper method:

    Code:
    import org.springframework.web.util.UrlPathHelper;
    
    ...
    
    UrlPathHelper pathHelper = new UrlPathHelper();
    pathHelper.setUrlDecode(true);
    String uri = pathHelper.getRequestUri(myHttpServletRequestObject);
    
    ...
    You can then carry on using the uri string normally in the UrlFileNameViewController.

    Dumbdare

    Comment

    Working...
    X