1. getAttribute得到的是对象,getParameter得到的是String
2. 重定向时,parameter的值会丢失,但attribute的值还在
3.
——getParameter()是获取POST/GET传递的参数值;
——getAttribute()是获取对象容器中的数据值;
——getParameter:用于客户端重定向时,即点击了链接或提交按扭时传值用,即用于在用表单或url重定向传值时接收数据用。
——getAttribute:用于服务器端重定向时,即在sevlet中使用了forward函数,或struts中使用了mapping.findForward。getAttribute只能收到程序用setAttribute传过来的值。
4.request.getParameter()的特殊用法:
因为getParameter()可以获取POST/GET传递的参数值,表单form也是通过POST/GET
传递数据的,所以parameter是html裡傳來的像 checkbox textfield password radio ...的value
所以request.getParameter(property);可以得到其value值,即可以绕过ActionForm,不用其提供的get方法就可以得到相应的值。
例如:
Action中就可以直接用
2. 重定向时,parameter的值会丢失,但attribute的值还在
3.
——getParameter()是获取POST/GET传递的参数值;
——getAttribute()是获取对象容器中的数据值;
——getParameter:用于客户端重定向时,即点击了链接或提交按扭时传值用,即用于在用表单或url重定向传值时接收数据用。
——getAttribute:用于服务器端重定向时,即在sevlet中使用了forward函数,或struts中使用了mapping.findForward。getAttribute只能收到程序用setAttribute传过来的值。
4.request.getParameter()的特殊用法:
因为getParameter()可以获取POST/GET传递的参数值,表单form也是通过POST/GET
传递数据的,所以parameter是html裡傳來的像 checkbox textfield password radio ...的value
所以request.getParameter(property);可以得到其value值,即可以绕过ActionForm,不用其提供的get方法就可以得到相应的值。
例如:
<html:select property="albumID" size="1">
<html:optionsCollection name="albumNamesMap" value="value" label="key" />
</html:select>
Action中就可以直接用
request.getParameter("albumID");
得到value值