分类: javaee

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");

相关文章:

  • 2022-01-22
  • 2021-09-20
  • 2021-10-08
  • 2021-11-01
  • 2021-11-11
  • 2021-12-03
  • 2021-12-25
  • 2021-11-06
猜你喜欢
  • 2021-10-08
  • 2021-10-08
  • 2021-10-20
  • 2021-11-06
  • 2021-11-06
  • 2021-12-03
  • 2022-01-16
相关资源
相似解决方案