1.先来个简单的form表单 login.jsp,建在webcontent目录下
Insert title here账号:
密码:
2.建个login的servlet. eclipse创建的话直接右键项目,new-->servlet-->填写具体信息
package com.tcc;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class loginServlet
*/
public class loginServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String name = request.getParameter("username");
String password = request.getParameter("psaaword");
System.out.println("username"+name);
System.out.println("psaaword"+password);
自己去写逻辑处理,爱干嘛干嘛
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
}