返回登录页面后如何显示之前填写的信息
方法一:
<body>
<%
String username = "";
if(!session.isNew()) {
username = (String)session.getAttribute("username");
if(username == null) {
username = "";
}
}
%>
<form action="mailcheck.jsp">
username:<input type="text" name="username" value="<%= username %>">
<input type="submit" value="submit">
</form>
</body>
方法二:
<body>
<%
//请求转发时使用
//String username = (String)request.getAttribute("username");
//String authority = (String)request.getAttribute("authority");
//重定向时使用
String username = request.getParameter("username");
String authority = request.getParameter("authority");
%>
<form action="UserLoginServlet" method="post">
username:<input type="text" name="username" value="<%= null == username ? "" : username %>"><br>
password:<input type="password" name="password"><br>
authority: <select name="authority">
<option value="1" <%= "1".equals(authority) ? "selected='selected'" : "" %>>commom user</option>
<option value="2" <%= "2".equals(authority) ? "selected='selected'" : "" %>>administrator</option>
</select><br>
<input type="submit" value="submit">
</form>
</body>