About the back-end database normal storage Chinese through the Ajax way to the foreground into a question mark processing

Source: Internet
Author: User

One of my programs, used in the background database MySQL, field is varchar,character set is UTF8, the field can and has been correctly stored in Chinese.

After extracting the information from the database, debug in the background Java code to see the correct Chinese.

However, through the Ajax way to send information to the foreground, the front desk display?? , a two question mark is also viewed with alert.

Look at the page encoding method, <%@ page contenttype= "text/html; Charset=utf-8 "%> and <meta charset=" Utf-8 "/> all have.

Go back to the deal in action and discover that there are three important treatments forgotten about response, which are:

Response.setcontenttype ("Text/xml;charset=utf-8");
Response.setheader ("Cache-control", "No-cache");
Response.setcharacterencoding ("UTF-8");

Put these three words in

PrintWriter out =getprintwriter (response);

I'll be right ahead of you.

That's all, I hope to be helpful to people who have the same problems as me.

January 9, 2017 15:52:37

About the back-end database normal storage Chinese through the Ajax way to the foreground into a question mark processing

Related Article

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.