1. 程式人生 > ><a>標籤href屬性中加入漢字引數的亂碼解決

<a>標籤href屬性中加入漢字引數的亂碼解決

我已經在HTML頁面頂部設定了編碼為utf-8,但是在我點選超連結<a href="xx/username='張三'">後,我在後臺獲取的username變成了??,後來我發現<a>的請求編碼是iso-8859-1。我們需要在拿到username後進行轉碼操作。

username=new String(username.getBytes("iso-8859-1","utf-8"));

好了,問題解決。