只有保证服务器端,客户端,数据库三者编码格式相同,都为UTF-8
即客户端,在jsp文件中:<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
服务器端,在servlet java文件中:response.setContentType("text/html;charset=UTF-8"); response.setCharacterEncoding("UTF-8");
在server.xml文件中:<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="utf-8"/>(server.xml文件在tomcat\conf\)
主要解决问题:POST或者GET传值问题,SRC中文路径URL传值问题
转载请注明原文地址: https://ju.6miu.com/read-9722.html