html向servlet传乱码解决办法

html 设置为utf-8格式

<meta http-equiv="content-type" content="text/html;charset=UTF-8">

myeclipse里可以修改jsp编码格式,

request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");

String username = (String)request.getParameter("username");
username = new String(username.getBytes("iso8859-1"),"utf-8");

注释:通常表单使用get时,url中包含中文,接收会出现乱码。这是大部分浏览器会将url中的中文编码成iso8859-1.

原文地址:https://www.cnblogs.com/tuifeideyouran/p/3935336.html