Article Directory
Problem scenario
IE11
Under the environment, post
there is a garbled problem in submission; while under IE8-10
and 谷歌浏览器
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
IE11
post
The parameter encoding of the above request IE8
is 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!