</td>
</tr>
<tr>
<td>身份: </td>
<td>
<select name="form">//这里传值给servlet
<option value="读者"selected>读者</option>
<option value="管理员"selected>管理员</option>
</select>
</td>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" value="登录" onclick="return judge()" />
<a href="zhuce.jsp" >点击注册</a>
</td>
</tr>
</table>
reader.jsp//读者功能
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="Bean.*,java.util.ArrayList,util.*,dao.*,servlet.*"%>
Insert title here
浏览图书信息
查询图书信息
借阅图书
浏览催还书目
归还图书
genlist.jsp//管理员功能
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="Bean.*,java.util.ArrayList,util.*,dao.*,servlet.*"%>
管理员界面
添加读者信息
添加新书信息
打印催还书信息
二.servlet层
package servlet;
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;
import javax.servlet.http.HttpSession;
import Bean.xinxi;
import dao.dao;
import daoimpl.daoimpl;
/**
* Servlet implementation class login_servlet
*/
@WebServlet("/login_servlet")
public class login_servlet extends HttpServlet {
private static final long serialVersionUID = 1L;
dao gooddao=new daoimpl();
/**
* @see HttpServlet#HttpServlet()
*/
public login_servlet() {
super();
// TODO Auto-generated constructor stub
}
/\*\*
\* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
\*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request, response);
}
/\*\*
\* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
\*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String method=request.getParameter("method");
String form=request.getParameter("form");//获取来自denglu.jsp里面的数据if("login".equals(method)) { //通过判断语句进入不同页面if(form.equals("读者"))request.getRequestDispatcher("reader.jsp").forward(request, response);
else if(form.equals("管理员"))request.getRequestDispatcher("genlist.jsp").forward(request, response);
}
}
三.运行结果
这里只是一个前端页面,没有与数据库打交道,下一篇写验证账号密码是否正确,需要实现注册功能,连接数据库。
喜欢就点点关注吧!!! |