HttpServletRequest類getAttribute()和getParameter()的區(qū)別:
getParameter()用來(lái)接受從Web客戶端傳到Web服務(wù)器端的HTTP請(qǐng)求中g(shù)et方法或post方法傳遞的數(shù)據(jù),返回String類型的數(shù)據(jù)。HttpServletRequest類有setAttribute()方法,而沒有setParameter()方法。
setAttribute()和getAttribute()方法傳遞的數(shù)據(jù)只會(huì)存在于Web容器內(nèi)部,在具有轉(zhuǎn)發(fā)關(guān)系的Web組件之間共享。getAttribute()獲得的是由setAttribute()方法賦的值,返回值是Object。