Results 1 to 3 of 3

Thread: Spring MVC: @ModelAttribute decoded correctly but @RequestParam decoded wrongly

Threaded View

  1. #1
    Join Date
    Nov 2011
    Posts
    10

    Default Spring MVC: @ModelAttribute decoded correctly but @RequestParam decoded wrongly

    For @ModelAttribute scenario, the request is generated by browser.
    Here is the request information
    Code:
    Request URL:http://localhost:8080/Azelea/register
    Request Headersview source
    Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Content-Type:application/x-www-form-urlencoded
    Origin:http://localhost:8080
    Referer:http://localhost:8080/Azelea/register
    User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
    Form Dataview URL encoded
    email:sdf@mm.com
    password:11
    salutation:先生
    fullName:组件
    company.name:
    company.id:
    locale:zh_CN
    thanks for filter org.springframework.web.filter.CharacterEncodingFi lter in web.xml, the chinese character in salutation and fullName are read correctly by ModelAttribute in controller.

    For @RequestParam scenario, the request is generated by jQuery UI autocomplete.
    Here is the request information
    Code:
    Request URL:http://localhost:8080/Azelea/company/search?term=%E4%BA%A4%E4%BA%92
    Request Headersview source
    Accept:application/json, text/javascript, */*; q=0.01
    Referer:http://localhost:8080/Azelea/register
    User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
    X-Requested-With:XMLHttpRequest
    Query String Parametersview URL encoded
    term:交互
    Notice the term is correctly encoded as %E4%BA%A4%E4%BA%92
    but in this case, the controller get a wrong term: δΊ€δΊ’
    the signature of this controller is:
    Code:
    @RequestMapping(value = "/company/search", method = RequestMethod.GET)
    @ResponseBody 
    public List<Organization> findCompanyName(@RequestParam(required=false) String term) {
    where is the problem? why CharacterEncodingFilter can't work on second scenario?
    Last edited by truetime; Sep 18th, 2012 at 07:50 AM.

Tags for this Thread

Posting Permissions

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