Results 1 to 4 of 4

Thread: @RequestParam doesn't seem to be decoded

  1. #1
    Join Date
    Nov 2009
    Location
    London
    Posts
    11

    Default @RequestParam doesn't seem to be decoded

    Hi all

    I'm having a problem with a @RequestParam that gets passed in via querystring, and was hoping someone could point me in the right direction. The method signature looks like this:

    Code:
    @RequestMapping(value="/view.html", method=RequestMethod.GET)
    	public String viewUser(@RequestParam("username") String username, Model model) {
    ...
    }
    From what I can see in the Spring docs, DispatcherServlet enables the DefaultAnnotationHandlerMapping which decodes the servlet path (see http://static.springsource.org/sprin...handlermapping). Does this also automatically decode @RequestParam values before passing them to the handler method ("viewUser" in this case).

    To be more specific, I'm passing the username in the querystring - but the username may contain characters like ü (encoded as %FC in the URL).

    So my question is: How do I get this value provided in its decoded form?

    Thanks very much

    EDIT: I'm using v3.0.3 - just in case that question arises.

    EDIT2: I've also configured the CharacterEncodingFilter to use UTF-8 in web.xml

  2. #2
    Join Date
    Nov 2009
    Location
    London
    Posts
    11

    Default

    Anyone have any suggestions for this?

  3. #3
    Join Date
    Nov 2008
    Posts
    6

    Default

    I think I have the same problem here, when I tried to display ${param.my_param_name} in my jspx, the param_value was not decoded correctly. I already use CharacterEncodingFilter but it seems not work on my case.

    Code:
    <jsp:scriptlet>
    	//print out UTF-8
    	System.out.println(request.getCharacterEncoding());
    	//wrong value
    	System.out.println(request.getParameter("my_param_name"));
    </jsp:scriptlet>
    
    <!-- wrong value-->
    ${param.my_param_name}
    One way to get the job done if you are using tomcat (or something uses tomcat internally) is set URIEncoding="UTF-8" in Tomcat's <connector> settings within the "server.xml"

    More info can be found here:
    http://weblogs.java.net/blog/joconne...set_traps.html

    hth.
    Last edited by oppjinx; Aug 24th, 2010 at 01:21 AM.

  4. #4
    Join Date
    Jun 2009
    Posts
    5

    Thumbs up also Japanese language solved by it

    Thanks!
    This also solves the Japanese language problem.
    I modified /spring-insight-instance/conf/server.xml
    But still why don't Roo support it...

Posting Permissions

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