Home > Java > Java Tutorial > body text

How to solve the problem of garbled parameters received in java

王林
Release: 2020-05-21 16:20:00
Original
3477 people have browsed it

How to solve the problem of garbled parameters received in java

You can try the following five methods to solve the problem:

1. Submit in form instead of hyperlink

2. Through encodeURI (encodeURI(checkText)) method submits

Use URLDecoder.decode to decode in the java code:

Copy after login

Get Chinese in the java code:

String documentPath = (String) request.getParameter('documentPath');
documentPath = URLDecoder.decode(documentPath,"utf-8");
Copy after login

( Recommended video tutorial: java video)

3. Modify the connector in tomcat’s server.xml and add URLEncoding="UTF-8"

4. Chinese from java Transfer to jsp, and then transfer to java through url

Encoding in java:

URLEncoder.encode(URLEncoder.encode("传递的中文","utf-8"));
Copy after login

Decoding code in java:

URLDecoder.decode(request.getParameter('documentPath'),"utf-8");
Copy after login

5. Transcode the string in Java

String s = new String(filename.getBytes("ISO-8859-1"),"UTF-8");
Copy after login

Recommended tutorial: Getting started with java development

The above is the detailed content of How to solve the problem of garbled parameters received in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!