以下就是為大家分享的URL地址傳輸參數亂碼的解決方法:
1.在tomcat中配置:在tomcat安裝目錄下面找到conf下面的server.xml找到以下代碼段,修改URIEncoding為GBK;
1
2
3
|
< Connector port = "8080" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443" URIEncoding = "GBK" /> |
2.用java實現:
1
2
3
4
5
6
7
8
9
10
11
12
|
String username = request.getParameter( "userName" ); try { username = new String(username.getBytes( "iso-8859-1" ), "GBK" ); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } |
之前小編都是靠這種方法解決 Java 地址參數亂碼的問題,希望本文也能幫助到大家。