Servlet登入页面
login
package com.zhongruan.servlet;
import com.zhongruan.model.User;
import com.zhongruan.service.IUserService;
import com.zhongruan.service.impl.UserServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.List;
public class LoginServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String username=request.getParameter(“username”);
String password=request.getParameter(“password”);
IUserService userService=new UserServiceImpl();
Boolean flag=userService.login(username,password);
if(flag){
request.getRequestDispatcher("/find").forward(request,response);
}else {
request.getRequestDispatcher(“failure.jsp”).forward(request,response);
}
}
}
index.jsp
<%@ page contentType=“text/html;charset=UTF-8” language=“java” %>
main
failure
web
无连接数据库的界面 (含css)