1 package com.zzw.LoginServelt; 2 3 import java.io.IOException; 4 import java.io.PrintWriter; 5 6 import javax.servlet.ServletException; 7 import javax.servlet.http.HttpServlet; 8 import javax.servlet.http.HttpServletRequest; 9 import javax.servlet.http.HttpServletResponse; 10 11 public class LoginServelt extends HttpServlet { 12 public void doGet(HttpServletRequest request, HttpServletResponse response) 13 throws ServletException, IOException { 14 15 response.setContentType("text/html;charset=UTF-8"); 16 PrintWriter out = response.getWriter(); 17 String username = request.getParameter("username"); 18 System.out 19 .println(new String(username.getBytes("ISO-8859-1"), "utf-8")); 20 out.write("连接成功"); 21 out.flush(); 22 out.close(); 23 } 24 25 public void doPost(HttpServletRequest request, HttpServletResponse response) 26 throws ServletException, IOException { 27 this.doGet(request, response); 28 } 29 30 }