Results 1 to 2 of 2

Thread: Url view controller and escaped characters

  1. #1
    Join Date
    Jan 2006
    Posts
    9

    Question 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. #2
    Join Date
    Jan 2006
    Posts
    9

    Default 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •