第十周作业
<form action="jump.jsp" method="post"> <table> <tr> <td>用户名</td> <td><input type="text" name="uname" /></td> </tr> <tr> <td>密码</td> <td><input type="text" name="upwd" /></td> </tr> <tr> <td>年龄</td> <td><input type="text" name="uage"/></td> </tr> <tr> <td><input type="submit" value="注册" /></td> <td><a href="login.jsp">登录</a></td> </tr> </table> </form>
<body> <% String uname = request.getParameter("uname"); String upwd = request.getParameter("upwd"); StuDao s1 = new StuDao(); if (s1.login(uname, upwd)) { request.getRequestDispatcher("true.jsp").forward(request, response); } else { request.getRequestDispatcher("false.jsp").forward(request, response); } %> </body>
<body> <% String name = request.getParameter("name"); String passwords = request.getParameter("password"); String ages = request.getParameter("age"); int age = Integer.parseInt(ages); int password = Integer.parseInt(passwords); StuDao s1 = new StuDao(); s1.reg(name, password, age); request.getRequestDispatcher("login.jsp").forward(request, response); %> </body>
<body> <% request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); String uname = request.getParameter("uname"); String password = request.getParameter("password"); Integer age = Integer.parseInt(request.getParameter("age")); User user = new User(uname, password, age); UserDao userDao = new UserDao(); userDao.regUser(user); response.sendRedirect("login.jsp"); %> </body>