public class ServletDemo extends HttpServlet{
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
System.out.println("11111");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
this.dopost(request,reponse);
}
上面是一段简单的servlet代码
在servlet中doget和dopost方法相同
在javaweb开放中出现乱码问题说明网页编码与工具编码不一致
request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8");
使用这窜代码可以有效解决,也可以在编程工具中设置编码为utf-8