赞
踩
系统一共分为4个角色分别是:管理员,学生,辅导员,企业
- <%@ page language="java" contentType="text/html; charset=utf-8"
- pageEncoding="utf-8"%>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
- + path + "/";
- %>
-
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>大学生实习平台</title>
- <meta name="renderer" content="webkit">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
- <link rel="stylesheet" type="text/css" href="<%=path %>/layui/css/layui.css">
- <link rel="stylesheet" type="text/css" href="<%=path %>/layui/css/admin.css">
- <link rel="stylesheet" type="text/css" href="<%=path %>/layui/css/login.css">
- </head>
- <body >
-
-
- <form method="post" id="loginForm" >
- <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
- <div class="layadmin-user-login-main">
- <div class="layadmin-user-login-box layadmin-user-login-header">
- <h2 style="font-size:50px;">大学生实习平台登陆</h2>
-
- </div>
- <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
- <div class="layui-form-item">
- <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-cellphone"></label>
- <input type="text" name="username" lay-verify="username" id="username" placeholder="用户名" class="layui-input">
- </div>
-
- <div class="layui-form-item">
- <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
- <input type="password" name="password" lay-verify="password" id="password" placeholder="密码" class="layui-input">
- </div>
-
- <div class="layui-form-item" style="align:center;">
- <select name="type" id="type" >
- <option value="0" >管理员</option>
- <option value="1" >辅导员</option>
- <option value="2" >学生</option>
- <option value="3" >企业</option>
- </select>
- </div>
- <div class="layui-form-item">
- <!-- <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-reg-submit">注 册</button> -->
- <button type="button" id="login" class="layui-btn layui-btn-fluid">登陆</button>
-
- </div>
- -<!-- <div class="layui-form-item">
- <a type="button" id="register" class="layui-btn layui-btn-fluid" >注册学生</a>
- </div>
-
- <div class="layui-form-item">
- <a type="button" id="register2" class="layui-btn layui-btn-fluid" >注册代取员</a>
- </div> -->
-
- </div>
- </div>
-
-
-
- </div>
- </form>
-
-
-
- <script src="<%=path %>/layui/layui.js"></script>
- <script src="<%=path %>/layui/jquery-1.9.1.min.js"></script>
-
- <script>
- $("#login").click(function(){
- var username = $("#username").val();
- var password = $("#password").val();
- if(username == null || username == ""){
- alert("请填写用户名");
- return false;
- }if(password == null || password == ""){
- alert("请填写密码");
- return false;
- }
- //执行添加的操作ajax
- $.ajax({
- cache:true,
- type:"post",
- url:"login",
- data:$("#loginForm").serialize(),
- async:false,
- success:function(e){
- if(e == "ok"){
- alert("登录成功");
- window.location.href="toMain";
- }else if(e == 'toIndex'){
- alert("登录成功");
- window.location.href="toIndex";
- }else{
- alert("登录失败,账号或密码错误");
- }
- }
- })
- });
- </script>
-
-
- <script>
-
- layui.use([ 'form','jquery','layer' ], function() {
- var form = layui.form,
- layer = layui.layer,
- $= layui.jquery;
- form.render();//这句一定要加,占坑
-
- $('#register').on("click",function(e){
- layer.open({
- //调整弹框的大小
- area:['500px','800px'],
- shadeClose:true,//点击旁边地方自动关闭
- //动画
- anim:2,
- //弹出层的基本类型
- type: 2,
- title: '注册学生',
- //刚才定义的弹窗页面
- content: 'toRegister', //这里content是一个URL,如果你不想让iframe出现滚动条,你还可以content: ['http://sentsin.com', 'no']
-
- });
- });
-
- $('#register2').on("click",function(e){
- layer.open({
- //调整弹框的大小
- area:['500px','800px'],
- shadeClose:true,//点击旁边地方自动关闭
- //动画
- anim:2,
- //弹出层的基本类型
- type: 2,
- title: '注册代取员',
- //刚才定义的弹窗页面
- content: 'toRegisterAgent', //这里content是一个URL,如果你不想让iframe出现滚动条,你还可以content: ['http://sentsin.com', 'no']
-
- });
- });
-
-
- });
- </script>
- </body>
- </html>
- /**
- * 登录
- * @param username
- * @param request
- * @param password
- * @param session
- * @param response
- * @param mv
- * @return
- * @throws ServletException
- * @throws IOException
- */
- @RequestMapping("/login")
- @ResponseBody
- public String login(@RequestParam("username")String username,
- HttpServletRequest request,@RequestParam("password")String password,
- HttpSession session,HttpServletResponse response,ModelAndView mv) throws ServletException, IOException {
- String message = "no";
- session.removeAttribute("admin");
- session.removeAttribute("user");
- String type=request.getParameter("type").toString();
- request.getSession().setAttribute("type", type);
- if(type != null && type.equals("1")){
- Instructor data = InstructorService.selectInstructor(username,password);
- if(data != null){
- request.getSession().setAttribute("instructor", data);
- session.setAttribute("instructor", data);
- message = "ok";
- }
- }else if(type != null && type.equals("2")){
- Student te = userService.selectStudent(username,password);
- if(te != null){
- request.getSession().setAttribute("student", te);
- session.setAttribute("student", te);
- message = "toIndex";
- }
- }else if(type != null && type.equals("0")){
- Admin te = adminService.selectAdmin(username,password);
- if(te != null){
- request.getSession().setAttribute("admin", te);
- session.setAttribute("admin", te);
- message = "ok";
- }
- }else if(type != null && type.equals("3")){
- Company company = CompanyService.selectCompany(username,password);
- if(company != null){
- request.getSession().setAttribute("company", company);
- session.setAttribute("company", company);
- message = "ok";
- }
- }
- return message;
-
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。