Problem solving: In IE11 environment, garbled characters appear in post submission

Problem scenario

IE11Under the environment, postthere is a garbled problem in submission; while under IE8-10and 谷歌浏览器under, there will be no 乱码problem. This blog post proposes a targeted solution.

Problem environment

software version
JDK 6
tomcat 7.0.29
JQuery 1.7.1

problem causes

IE11postThe parameter encoding of the above request IE8is different from the environment, which causes the problem to occur.

solution

Do it for the Chinese parameters 加密, and then do it on the server side 解密. This can avoid problems caused by differences in browser versions. Here is the code for the front and back ends:

front end

// 对中文做加密,后端做解密,避免出问题
json.oldFileName = encodeURI(json.oldFileName)

Backstage

String oldFileName = java.net.URLDecoder.decode(request.getParameter("oldFileName"),request.getCharacterEncoding());

result

The front and back ends are displayed normally, which solves the problem of garbled characters.

to sum up

There are tens of thousands of problems, grasp the ideas and solve them!

Ask for praise

If my article is helpful to everyone, you can click like or favorite at the bottom of the article;
if there is a good discussion, you can leave a message;
if you want to continue to view my future articles, you can click Follow
You can scan the following QR code to follow me 'S public account: Fengye Zhixuege, check out my latest share!
Insert picture description here
Bye bye

Guess you like

Origin blog.csdn.net/u013084266/article/details/112892234