setAttribute、getAttribute和getParameter

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_35221883/article/details/79502503
request.getAttribute()方法返回request范围内存在的对象,而request.getParameter()方法是获取http提交过来的数据
getParameter()是 获取POST/GET传递的参数值;用于 客户端重定向时,即点击了链接或提交按钮时传值用,即用于在用表单或url重定向传值时接收数据用。
getAttribute()是 获取对象容器中的数据值,用于 服务器端重定向时,即在servlet中使用了forword函数,或struts中使用了mapping,findForword,getAttribute只能收到程序用setAttribute传过来的值

猜你喜欢

转载自blog.csdn.net/weixin_35221883/article/details/79502503