<form action="register1" method="get">
用户名:<input type="text" name="username" value='aaa'><br>
</form>
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String str=req.getParameter("username");
PrintWriter pw=resp.getWriter();
pw.println(str);
pw.println("刷刷刷");
}
为什么第一个不是乱码,第二个是乱码
输出语句前加两个语句resp.contentype("text/html")resp.***encoding("utf-8")
resp.setCharacterEncoding("utf-8");
resp.setContentType("text/html;charset=utf-8");