getParameter和getAttribute的区别
轉(zhuǎn)自http://blog.csdn.net/java_xiaobin/article/details/45363897
?
1.getAttribute是取得jsp中?用setAttribute設(shè)定的attribute?
2.parameter得到的是string;attribute得到的是object?
3.request.getParameter()方法傳遞的數(shù)據(jù),會(huì)從Web客戶端傳到Web服務(wù)器端,代表HTTP請(qǐng)求數(shù)據(jù);request.setAttribute()和getAttribute()方法傳遞的數(shù)據(jù)只會(huì)存在于Web容器內(nèi)部,在具有轉(zhuǎn)發(fā)關(guān)系的Web組件之間共享。即request.getAttribute()方法返回request范圍內(nèi)存在的對(duì)象,而request.getParameter()方法是獲取http提交過來的數(shù)據(jù)。
?
總結(jié):
getattribute一般在前臺(tái)用與獲取后臺(tái)轉(zhuǎn)發(fā)值
getParameter一般在后臺(tái)用于獲取前臺(tái)請(qǐng)求值
getParameter??返回的是String?用于讀取參數(shù)中的值;???????
getAttribute???返回的是Object,需進(jìn)行轉(zhuǎn)換,可用setAttribute設(shè)置成任意對(duì)象,使用很靈活,可隨時(shí)用;
getParameter??獲取請(qǐng)求值???????
getAttribute?? 獲取轉(zhuǎn)發(fā)值
轉(zhuǎn)載于:https://www.cnblogs.com/wangshen31/p/8335363.html
總結(jié)
以上是生活随笔為你收集整理的getParameter和getAttribute的区别的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MySQL 类型转换
- 下一篇: Scala学习之爬豆瓣电影