PrintWriter out =response.getWriter();为什么会错误?
改成PrintWriter out = new PrintWriter(res.getOutputStream())就可以了?
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("!"); // 检验
String piccode =(String)request.getSession().getAttribute("piccode");
String checkcode =request.getParameter("checkcode");
checkcode =checkcode.toUpperCase();
System.out.println(checkcode+" "+piccode); // 检验
response.setCharacterEncoding("text/html;charset=utf-8");
System.out.println("!!"); // 检验
//PrintWriter out =response.getWriter(); //错误
PrintWriter out =new PrintWriter(response.getOutputStream()); //正确
System.out.println("!!!"); // 检验
if(checkcode.equals(piccode))
{
out.println("验证码输入正确");
}
else
{
out.println("验证码输入错误");
}
out.flush();
out.close();
}