標籤:
分類: javaee2015-07-09 16:35 29人閱讀 評論(0) 收藏 編輯 刪除
post 中文亂碼解決方式
接受資料的時候設定
request.setCharacterEncoding("utf-8");//編碼必須和頁面編碼一致
版面設定
<%@page import="java.net.URLDecoder"%> <%@page import="org.apache.naming.java.javaURLContextFactory"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
get中文亂碼
修改tomcat server.xml
增加 URIEncoding="utf-8" 設定編碼
<Connector URIEncoding="utf-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
執行個體:
<a href="ppsd.jsp?a=盤兩條">654465465654</a>
Servlet 後台跳轉頁面url中有中文
response.sendRedirect("ppsd.jsp?a=46565464564"+URLEncoder.encode("阿斯頓發放","utf-8")+"99999");
Javaee中文亂碼解決方案