JSP中param動(dòng)作的實(shí)例詳解
JSP中param動(dòng)作的實(shí)例詳解
一 語(yǔ)法
<jsp:param name="參數(shù)名" value="參數(shù)值">
常常與<jsp:forward>一起使用,作為其子標(biāo)簽存在。
二 代碼
1、login.jsp
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" > <title>My JSP 'login.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" > --> </head> <body> <h1>系統(tǒng)登錄</h1> <hr> <form name="loginForm" action="dologin.jsp" method="post"> <table> <tr> <td>用戶(hù)名:</td> <td><input type="text" name="username"/></td> </tr> <tr> <td>密碼:</td> <td><input type="password" name="password"/></td> </tr> <tr> <td colspan="2"><input type="submit" value="登錄"/></td> </tr> </table> </form> </body> </html>
2、dologin.jsp
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" > <title>My JSP 'dologin.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" > --> </head> <body> <jsp:forward page="user.jsp"> <jsp:param value="admin@123.net" name="email"/> <jsp:param value="888888" name="password"/> </jsp:forward> </body> </html>
3、user.jsp
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" > <title>My JSP 'user.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" > --> </head> <body> <h1>用戶(hù)資料</h1> <hr> <% request.setCharacterEncoding("utf-8"); String username = ""; String password = ""; String email = ""; if(request.getParameter("username")!=null) { username = request.getParameter("username"); } if(request.getParameter("password")!=null) { password = request.getParameter("password"); } if(request.getParameter("email")!=null) { email = request.getParameter("email"); } %> 用戶(hù)名:<%=username %><br> 密碼:<%=password %><br> 電子郵箱:<%=email %><br> </body> </html>
三 運(yùn)行結(jié)果
如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
- JSP中的編譯指令和動(dòng)作指令的兩點(diǎn)區(qū)別
- jsp的常用指令有哪些(編譯指令/動(dòng)作指令整理)
- 十三、JSP動(dòng)作
- 在JSP頁(yè)面中動(dòng)態(tài)生成圖片驗(yàn)證碼的方法實(shí)例
- SpringBoot+jsp項(xiàng)目啟動(dòng)出現(xiàn)404的解決方法
- spring boot整合jsp及設(shè)置啟動(dòng)頁(yè)面的方法
- JSP頁(yè)面的靜態(tài)包含和動(dòng)態(tài)包含使用方法
- jsp-解決文件上傳后重啟Tomcat時(shí)文件自動(dòng)刪除問(wèn)題
- JSP常用七大動(dòng)作指令實(shí)例解析
相關(guān)文章
JDBCTM 指南:入門(mén)7-CallableStatement
JDBCTM 指南:入門(mén)7-CallableStatement...2006-10-10解決cannot be cast to javax.servlet.Filter 報(bào)錯(cuò)的問(wèn)題
本文主要介紹解決cannot be cast to javax.servlet.Filter 報(bào)錯(cuò)的問(wèn)題,這里提供解決辦法,有編程的朋友遇到此錯(cuò)誤可以參考下2016-08-08jsp頁(yè)面中引用其他頁(yè)面的簡(jiǎn)單方法
下面小編就為大家?guī)?lái)一篇jsp頁(yè)面中引用其他頁(yè)面的簡(jiǎn)單方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-06-06jsp實(shí)現(xiàn)checkbox的ajax傳值實(shí)例
這篇文章主要介紹了jsp實(shí)現(xiàn)checkbox的ajax傳值,實(shí)例分析了針對(duì)checkbox的Ajax使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-02-02