For @ModelAttribute scenario, the request is generated by browser.
Here is the request information
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.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
For @RequestParam scenario, the request is generated by jQuery UI autocomplete.
Here is the request information
Notice the term is correctly encoded as %E4%BA%A4%E4%BA%92Code: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:交互
but in this case, the controller get a wrong term: δΊ€δΊ’
the signature of this controller is:
where is the problem? why CharacterEncodingFilter can't work on second scenario?Code:@RequestMapping(value = "/company/search", method = RequestMethod.GET) @ResponseBody public List<Organization> findCompanyName(@RequestParam(required=false) String term) {


Reply With Quote
