改成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();
}
response是不是为null
是你的servlet的编码格式的语句写错了,应该这样的 response.setContentType("text/html;charset=utf-8");
我也是这个问题 怎么破
out没有实例化对象吧。。