java登录分角色_公文流转系统部分之分角色登录

packagecom.xk.servlet;importjava.io.IOException;importjava.io.UnsupportedEncodingException;importjava.util.ArrayList;importjava.util.List;importjavax.servlet.ServletException;importjavax.servlet.annotation.WebServlet;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;//import javax.smartcardio.ResponseAPDU;

importcom.xk.bean.user;importcom.xk.bean.user1;importcom.xk.bean.user2;importcom.xk.bean.user3;importcom.xk.dao.Dao;/*** Servlet implementation class CourseServlet*/@WebServlet("/Servlet")public class Servlet extendsHttpServlet {private static final long serialVersionUID = 1L;publicServlet() {super();

}protected void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub//response.getWriter().append("Served at: ").append(request.getContextPath());

response.setContentType("text/html;charset=UTF-8");

request.setCharacterEncoding("UTF-8");

String method= request.getParameter("method");if(method.equals("dopost"))

{

dopost(request,response);

}

}private void dopost(HttpServletRequest requst, HttpServletResponse response) throwsIOException, ServletException{

requst.setCharacterEncoding("utf-8");

String username= requst.getParameter("username");

String password= requst.getParameter("password");

String id1= requst.getParameter("id1");

System.out.println(username);

Dao dao=newDao();

user course= newuser(username,password,id1);

String id=dao.dopost(course);if(id.equals("0")) {

requst.setAttribute("message", "登录失败!");

requst.getRequestDispatcher("index.jsp").forward(requst,response);

}else if(id.equals("1")) {

requst.setAttribute("message", "登陆成功!");

requst.getRequestDispatcher("manager.jsp").forward(requst,response);

}else if(id.equals("2")) {

requst.setAttribute("message", "登陆成功!");

requst.getRequestDispatcher("teacher.jsp").forward(requst,response);

}else if(id.equals("3")) {

requst.setAttribute("message", "登陆成功!");

requst.getRequestDispatcher("student.jsp").forward(requst,response);

}

}protected void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {//TODO Auto-generated method stub

doGet(request, response);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值