输出提示信息
創建StringUtil的JavaBean類,判斷用戶名和密碼
創建index.jsp頁面
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <form action="login.jsp" method="post"><table><tr><td align="right">請輸入同戶名:</td><td><input type="text" name="name"></td></tr><tr><td>請輸入密碼:</td><td><input type="password" name="pwd"></td></tr><tr><td colspan="2" align="center"><input type="submit" value="登錄"></td></tr></table> </form> </body> </html>創建login.jsp頁面,驗證用戶登錄信息
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <%String name=request.getParameter("name");String pwd=request.getParameter("pwd"); %> <jsp:useBean id="strBean" class="com.cn.zj.test.StringUtil"></jsp:useBean> <jsp:setProperty property="name" name="strBean" value="<%=name %>"/> <jsp:setProperty property="pwd" name="strBean" value="<%=pwd %>"/> <table><tr><td align="right">提示信息:</td><td><!-- 從StringUtil對象中獲得屬性值 --><jsp:getProperty property="cue" name="strBean"/></td></tr><tr><td colspan="2" align="center"><a href="index.jsp">返回</a></tr> </table> </body> </html>總結
- 上一篇: 计算两个日期相差的天数
- 下一篇: 输出分页导航的方法