Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法获取URL中的中文字符_Java_Forms_Jsp_Utf 8_Cjk - Fatal编程技术网

Java 无法获取URL中的中文字符

Java 无法获取URL中的中文字符,java,forms,jsp,utf-8,cjk,Java,Forms,Jsp,Utf 8,Cjk,我有一个网址:http://localhost:8080/Test/jsp/index.jsp?userName=%E5%AE%98%E8%AF%9D。但是当我试图获取用户名时: <meta http-equiv="test" content="text/html; charset=UTF-8"> <% String username = request.getParameter("userName"); out.print("<b>"+user

我有一个网址:
http://localhost:8080/Test/jsp/index.jsp?userName=%E5%AE%98%E8%AF%9D
。但是当我试图获取
用户名时:

<meta http-equiv="test" content="text/html; charset=UTF-8">
  <%
    String username = request.getParameter("userName");
    out.print("<b>"+username+"</b>");    
  %>


打印的
用户名
不可读。我的页面已经是UTF-8,并且也保存为UTF-8,如何获取和打印准确的中文字符?

您应该对URL进行编码(这是Python,使用等效的Java方法):


您应该对URL进行编码(这是Python,使用等效的Java方法):


你用的是什么?您可能需要将uriencoding设置为utf-8。您使用的是什么?您可能需要将uriencoding设置为utf-8。
>>> urllib.urlencode({'userName':'官话'})
'userName=%E5%AE%98%E8%AF%9D'