java乱码处理

utf8解决JSP中文乱码问题 
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%><%request.setCharacterEncoding("UTF-8");%> 

 

  在java中处理乱码问题

String msg = request.getParameter("message");
String str=new String(msg.getBytes("ISO-8859-1"),"UTF-8");

   在web.xml处理乱码

  

  <filter>   <filter-name>Set   Character   Encoding</filter-name>   <filter-class>filters.SetCharacterEncodingFilter</filter-class>   <init-param>   <param-name>encoding</param-name>   <param-value>GBK</param-value>   </init-param>   </filter>   <filter-mapping>   <filter-name>Set   Character   Encoding</filter-name>   <url-pattern>/*</url-pattern>   </filter-mapping> 

 

打开tomcat的server.xml文件

 URIEncoding=”GBK”

 

  

你可能感兴趣的:(java)