1. About JSP On the page pageEncoding and contentType The difference between the two properties :

pageEncoding yes jsp The encoding of the file itself ,contentType Of charset It refers to the content encoding when the server sends it to the client ,JSP It's going through two times “ code ”,

The first stage :jsp Translate it into .java The document will be used pageEncoding,

The second stage : From the source .java To bytecode .class Will use utf-8 to utf-8,

The third stage is made up of Tomcat The page that came out , It's using contentType.

2. All use UTF-8

resp.setHeader("Content-Type", "text/html;charset=UTF-8");

3.tomcat Under the table of contents conf/server.xml file

Character encoding solutions :<Connector port="80" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true"useBodyEncodingForURI="true" />

useBodyEncodingForURI It's based on the page responding to the request request.setCharacterEncoding Re encoding of data by parameters , Different pages can have different recoding codes .

You can also set URIEncoding=" Specified encoding ", But it's not a good way , If tomcat There are multiple projects , Each item is coded differently , It doesn't work .

URIEncoding and useBodyEncodingForURI The difference is that ,URIEncoding It's for all GET In this way, the requested data is uniformly re encoded , and useBodyEncodingForURI It's based on the page responding to the request request.setCharacterEncoding Re encoding of data by parameters , Different pages can have different recoding codes .

Ajax Return to more related articles about garbled code

  1. jquery ajax Return value When Chinese is garbled or becomes a question mark solution

    Reprinted from jquery Of ajax Return value for Chinese garbled solution use jquery Of ajax, Problems encountered , There is no Chinese garbled problem in the data that the server gets from the database ( There is no garbled code in the log ), But when it's delivered asynchronously to the customer, it appears ...

  2. ajax European characters returned ( for example : French ) The statement

    ajax The related code generated by the garbled return value is as follows : Java Code : JsonObject jsonObject = new JsonObject(); jsonObject.addProperty(&quo ...

  3. solve ajax Chinese code scrambling

    Major problems : One .ajax The data submitted to the server is in Chinese , No encoding set . Cause the server to receive garbled code Two . Server to the ajax The returned data contains Chinese , No response encoding set , cause ajax Received garbled code The cause of garbled code : No matter ...

  4. AJAX Chinese garbled PHP Perfect solution (IE and Firefox compatible )

    I've been working on a project recently , encounter AJAX Chinese code scrambling , After one afternoon's hard work, it was finally solved perfectly , Now write down the experience , I hope it can help those who are still struggling with this problem . as everyone knows , Use AJAX When transmitting and receiving Chinese parameters , If you're not here ...

  5. jQuery AJAX Chinese scrambling

    I've been working with jQuery ajax Back to garbled code , With Notepad++ Editor , When JS When part of the transmission is in Chinese , Another page will appear garbled if received , I found a lot of ways on the Internet , Basically, there is no good solution . Page use GB2312 code ,JS ...

  6. ajax Summary of the problem of Chinese garbled code

    ajax Summary of the problem of Chinese garbled code 2010-12-11 22:00 5268 Human reading Comment on (1) Collection report ajaxurljavascriptservletcallback The server This chapter deals with AJAX Common in ...

  7. spring MVC 3.2 in @ResponseBody(Post Interface ) Return to the perfect solution for garbled code

    Originally because ajax Cross domain http There was a problem with the remote call , When the server responds, it solves the problem in the following way , but IE8 And then there's a problem . response.addHeader("Access-Control-Allow-Orig ...

  8. 11 month 15 On the afternoon of Sunday ajax The return data type is XML Data processing

    ajax The return data type is XML Data processing /*XML: Extensible markup language HTML: Hypertext markup language label :< Tag name ></ Tag name > characteristic : 1. There has to be a root 2. Tag name customization 3. Yes ...

  9. 11 month 13 The morning of ajax The return data type is JSON Data processing

    ajax The return data type is JSON Data processing <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &qu ...

Random recommendation

  1. android Development ------ Write a linear layout of the user interface

    A good application can't do without a user-friendly interface . Before learning anything else . You should learn the layout of the program first ( appearance ) today , We're going to learn android Of UI Layout ----LinearLayout. LinearLayout, namely ...

  2. Codeoforces 558 B. Duff in Love

    //   B. Duff in Love time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  3. C++ Programming practice (14)-------“ The singleton pattern ” The implementation of the

    original text :http://blog.csdn.net/oohaha_123/article/details/25190833 The singleton pattern Singleton pattern is a common software design pattern . In its core structure, there is only one instance called singleton ...

  4. Delete GPT Protection zones

    problem : Will be built in and / Or an external hard disk connected to Windows XP 32 Bit operating system , Will not be able to access the hard disk ,“ Disk management ” It will be reported that the hard disk contains GPT Protection zones . In this state , The hard disk will not be repartitioned and formatted . reason : ...

  5. SQLite Query for

    using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...

  6. regular expression (php function )

    1. Regular expressions are a tool for string search and matching 2. php Regular expression functions are commonly used in preg_match($pattern, $subject) preg_match_all($pattern, $sub ...

  7. tar.gz tar.bz2 decompression

    Download the source code package from the network , The most common is .tar.gz package , Another part is .tar.bz2 package   It's easy to decompress :   .tar.gz     The format is           tar   -zxvf   ...

  8. cookie And sessionStorage Mechanism

    sessionStorage.localStorage and cookie The difference between Common ground : It's all saved on the browser side . And homologous   difference : 1.cookie Data is always in the same source http Carry... In the request ( Even if you don't need ), namely cooki ...

  9. python Assignment in , Deep copy , Shallow copy difference

    These three The difference is that Copied variables Whether it is a reference to the original variable . assignment : It's just a reference to the original variable . The difference between a shallow copy and a deep copy Need to pass through Subelement distinguish Shallow copy : The child element Same reference Deep copy : So the references are not the same , Make a complete copy of These three ...

  10. BZOJ 4552: [Tjoi2016&amp;Heoi2016] Sort Line segment tree Two points

    Catalog This code is a fake code , I can only fool luogu, I'll change it later , If you pass by, you can help me update 10.6 This code is a fake code , I can only fool luogu, I'll change it later , If you pass by, you can help me /* //fang zhi ...