【getAttribute、getParameter】&【setAttribute、"setParameter"】的区别

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/crossing2012/article/details/86506497

1.getParameter()方法用来获取客户端通过get或者post传递过来的参数,它的返回值永远是String类型。参数为页面提交的参数,包括:表单(post方式)提交的参数、URL重写(get方式)(如xxx?id=1中的id)传来的参数等,因此这个并没有setParameter()方法。

2.getAttribute()方法用于获取request对象中的attribute值,该方法的返回类型为object类型,attribute中的值是服务器端放入到request对象里的,通过调用request对象的setAttribute(key ,value)方法。注意:这里强调的是attribute中的值是在服务器端赋值的,而非客户端送过来的。

猜你喜欢

转载自blog.csdn.net/crossing2012/article/details/86506497