get請求的接口從頁面到controller類出現了亂碼。tomcat
參數亂碼:編碼
String param = "...";server
使用new String(param.getBytes("iso-8859-1"), "utf-8"); 強制將此字符串轉換成utf-8編碼 ,能夠轉換成正確的中文。xml
猜想多是網頁使用的iso-8859-1,到後臺沒有進行轉碼,若是每一個參數都手動轉碼,豈不是很麻煩,因此繼續百度。。。。。找到了解決方案。接口
在tomcat中的server.xml中設置編碼. 加一個URIEncoding就好了utf-8
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8"/>字符串