tomcat 中使用OutputStream传过来数据多两个空格
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String name = request.getParameter("name");
String age = request.getParameter("age");
System.out.println("POST");
System.out.println("name="+name);
System.out.println("age="+age);
response.setCharacterEncoding("UTF-8");
if(name.equals("q")&&age.equals("1")){
OutputStream out = response.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
writer.write("success");
writer.flush();
writer.close();
}else{
OutputStream out = response.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
writer.write("false");
writer.flush();
writer.close();
}
}
印度尼西亚之力
10 years, 6 months ago