How to obtain the returned value in Chinese garbled characters asynchronously using JQuery _ jquery-js tutorial

Source: Internet
Author: User
This article mainly introduces how to obtain Chinese garbled characters in return values asynchronously by JQuery. In addition to the normal encoding settings, you must set a setCharacterEncoding parameter to avoid garbled characters, if you want to obtain the List Value asynchronously using jqgrid, you can refer to the following: in case of a problem, the data obtained from the database on the server does not contain Chinese garbled characters (logs are not garbled ), however, garbled characters occur during asynchronous transmission to the customer. The server has been coded (UTF-8 encoding ). I started to suspect that it was a client problem. For example, the client and server encoding were inconsistent. I also suspected that the jqGrid tool function was missing the contentType: "application/x-www-form-urlencoded; charset = UTF-8 ", and so on.

None of the results. After several hours, I found that the original code was still on the server side and neglected.

@ RequestMapping (value = "/searchUserList. form ") @ ResponseBody public void searchUserList (int page, int rows, HttpServletRequest request, HttpServletResponse response) throws IOException {System. out. println ("idcard =" + idCard + "\ n page =" + page + "\ n rows =" + rows); List
 
  
List = userService. findByIDCard (idCard); int totalRecord = list. size (); int totalPage = totalRecord % rows = 0? TotalRecord/rows: (totalRecord/rows + 1); int index = (page-1) * rows; int pageSize = rows; String json = "{\" total \": \ "" + totalPage + "\", \ "page \": \ "" + page + "\", \ "records \": \ "" + totalRecord + "\", \ "rows \": ["; for (int I = index; I <pageSize + index & I
  
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.