下面是我们另一个登录的简单测试用的jsp文件
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>login.jsp页面</title>
</head>
<body>
<form action="loginCL.jsp" method="post" name=form >
<font size="5">登录界面</font><br>
用户名:<input type="text" value=""name="username"><br>
密 码:<input type="text"value="" name="password"><br>
<input type="submit"value="提交"name="submit">
<input type="reset"value="重置">
</form>
<%=(String)request.getAttribute("usertxt") %>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <html> <head> <title>loginCL.jsp页面</title> </head> <body> <% String referer = request.getHeader("Referer"); if(referer==null||referer.trim().length()==0|| !referer.equals("http://localhost:8080/denglu/login.jsp")){ response.sendRedirect("login.jsp"); return; } request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); String name=request.getParameter("username"); String password=request.getParameter("password"); //判断登陆界面的用户名和密码,根据输入的不同情况进行不同的处理 if(name.trim().equals("赵文哲")&&password.trim().equals("12345678")) { request.setAttribute("usertxt", "正常登录!!!"); request.getRequestDispatcher("success.jsp").forward(request, response); } else{ request.setAttribute("usertxt", "用户名或密码错误!!!"); request.getRequestDispatcher("login.jsp").forward(request, response); } %> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <html> <head> <title>success.jsp页面</title> </head> <body> <% String referer = request.getHeader("Referer"); if(referer==null||referer.trim().length()==0|| !referer.equals("http://localhost:8080/denglu/login.jsp")){ response.sendRedirect("login.jsp"); return; } request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); %> <%=(String)request.getAttribute("usertxt") %> </body> </html>
标签:web,Java,登录,success,jsp,页面 From: https://www.cnblogs.com/azwz/p/16858534.html