JAVA框架-Servlet上
package day27;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
-
Servlet implementation class LoginServlet
*/
@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println("服务器收到get请求!");
String username = request.getParameter("username");
String password = request.getParameter("password");
System.out.println("用户名:"+username );
System.out.println("密码:"+ password);
}protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println("服务器收到post请求!");
String username = request.getParameter("username");
String password = request.getParameter("password");
System.out.println("用户名:"+username );
System.out.println("密码:"+ password);
}
}
/*
服务器收到post请求!
用户名:123
密码:1111
服务器收到get请求!
用户名:1234
密码:22222222
*/