jsp部分亂碼(並不是沒有設置編碼的問題)
當頁面跳轉的時候,還是有中文的亂碼存在,最後發現我沒有寫頁面的提交方式,
<form action = "show.jsp">
用戶名:<input type="text" name = "uname"><br/>
密碼:<input type="password" name = "upwd"><br/>
年齡:<input type = "text" name = "uage"><br/>
愛好:<br/>
<input type = "checkbox" name = "uhobbies" value="乒乓球"/>乒乓球
<input type = "checkbox" name = "uhobbies" value="足球"/>足球
<input type = "checkbox" name = "uhobbies" value="籃球"/>籃球<br/>
<input type = "submit" value="註冊">
</form>
這就是之前的頁面的語句,會出現跳轉似的亂碼,
<form action = "show.jsp" method="post">
用戶名:<input type="text" name = "uname"><br/>
密碼:<input type="password" name = "upwd"><br/>
年齡:<input type = "text" name = "uage"><br/>
愛好:<br/>
<input type = "checkbox" name = "uhobbies" value="乒乓球"/>乒乓球
<input type = "checkbox" name = "uhobbies" value="足球"/>足球
<input type = "checkbox" name = "uhobbies" value="籃球"/>籃球<br/>
<input type = "submit" value="註冊">
</form>
加上method之後就沒有亂碼了,好了 問題解決了,原因是:
當我把程式碼中的post改為get之後,頁面的亂碼問題又出現了
如果不寫指定method的話,默認是使用get方式提交。
get的限制表單的數據集為ASCII碼。
而Post支援整個ISO10646字符集,默認是用ISO-8859-1
如果表單不顯示的聲明method為post,則默認為get。