JSP的setProperty的使用方法
JSP的setProperty的使用方法
一 介紹
<jsp:setProperty>作用
給已經(jīng)實(shí)例化的javabean對(duì)象的屬性賦值,一共有四種形式。
二 四種形式
三 實(shí)例
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" > <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" > --> </head> <body> <h1>系統(tǒng)登錄</h1> <hr> <form name="loginForm" action="dologin.jsp?mypass=999999" method="post"> <table> <tr> <td>用戶名:</td> <td><input type="text" name="username" value=""/></td> </tr> <tr> <td>密碼:</td> <td><input type="password" name="password" value=""/></td> </tr> <tr> <td colspan="2" align="center"><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" > <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" > --> </head> <body> <jsp:useBean id="myUsers" class="com.po.Users" scope="page"/> <h1>setProperty動(dòng)作元素</h1> <hr> <!--根據(jù)表單自動(dòng)匹配所有的屬性 --> <%-- <jsp:setProperty name="myUsers" property="*"/> --%> <!--根據(jù)表單匹配所有部分的屬性 --> <%-- <jsp:setProperty name="myUsers" property="username"/> --%> <!--根表單無(wú)關(guān),通過(guò)手工賦值給屬性 --> <%-- <jsp:setProperty name="myUsers" property="username" value="lisi"/> <jsp:setProperty name="myUsers" property="password" value="888888"/> --%> <!--通過(guò)URL傳參數(shù)給屬性賦值 --> <jsp:setProperty name="myUsers" property="username"/> <jsp:setProperty name="myUsers" property="password" param="mypass"/> <!-- 使用傳統(tǒng)的表達(dá)式方式來(lái)獲取用戶名和密碼 --> 用戶名:<%=myUsers.getUsername() %><br> 密碼:<%=myUsers.getPassword() %><br> <br> <br> </body> </html>
四 運(yùn)行結(jié)果
如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
上一篇:jsp中sitemesh修改tagRule技術(shù)分享
欄 目:JSP編程
下一篇:將properties文件的配置設(shè)置為整個(gè)Web應(yīng)用的全局變量實(shí)現(xiàn)方法
本文標(biāo)題:JSP的setProperty的使用方法
本文地址:http://mengdiqiu.com.cn/a1/JSPbiancheng/11439.html
您可能感興趣的文章
- 01-11Spring注入Date類型的三種方法總結(jié)
- 01-11web下載文件和跳轉(zhuǎn)的方法
- 01-11Properties 持久的屬性集的實(shí)例詳解
- 01-11在JSP中使用formatNumber控制要顯示的小數(shù)位數(shù)方法
- 01-11jsp文件下載功能實(shí)現(xiàn)代碼
- 01-11詳解Spring的核心機(jī)制依賴注入
- 01-11JSP頁(yè)面跳轉(zhuǎn)方法大全
- 01-11Spring獲取ApplicationContext對(duì)象工具類的實(shí)現(xiàn)方法
- 01-11jsp 使用request為頁(yè)面添加靜態(tài)數(shù)據(jù)的實(shí)例
- 01-11Spring依賴注入的三種方式實(shí)例詳解


閱讀排行
- 1C語(yǔ)言 while語(yǔ)句的用法詳解
- 2java 實(shí)現(xiàn)簡(jiǎn)單圣誕樹的示例代碼(圣誕
- 3利用C語(yǔ)言實(shí)現(xiàn)“百馬百擔(dān)”問(wèn)題方法
- 4C語(yǔ)言中計(jì)算正弦的相關(guān)函數(shù)總結(jié)
- 5c語(yǔ)言計(jì)算三角形面積代碼
- 6什么是 WSH(腳本宿主)的詳細(xì)解釋
- 7C++ 中隨機(jī)函數(shù)random函數(shù)的使用方法
- 8正則表達(dá)式匹配各種特殊字符
- 9C語(yǔ)言十進(jìn)制轉(zhuǎn)二進(jìn)制代碼實(shí)例
- 10C語(yǔ)言查找數(shù)組里數(shù)字重復(fù)次數(shù)的方法
本欄相關(guān)
- 01-11web下載文件和跳轉(zhuǎn)的方法
- 01-11Spring注入Date類型的三種方法總結(jié)
- 01-11在JSP中使用formatNumber控制要顯示的小
- 01-11Properties 持久的屬性集的實(shí)例詳解
- 01-11EJB3.0部署消息驅(qū)動(dòng)Bean拋javax.naming.Na
- 01-11jsp文件下載功能實(shí)現(xiàn)代碼
- 01-11JSP頁(yè)面跳轉(zhuǎn)方法大全
- 01-11詳解Spring的核心機(jī)制依賴注入
- 01-11jsp 使用request為頁(yè)面添加靜態(tài)數(shù)據(jù)的實(shí)
- 01-11Spring獲取ApplicationContext對(duì)象工具類的
隨機(jī)閱讀
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 01-11ajax實(shí)現(xiàn)頁(yè)面的局部加載
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
- 01-10delphi制作wav文件的方法
- 01-10使用C語(yǔ)言求解撲克牌的順子及n個(gè)骰子
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 04-02jquery與jsp,用jquery
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什
- 01-10C#中split用法實(shí)例總結(jié)