request.getParameter()是获得通过get或者post获得来的数据
getAttribute()是之前自己设定的
比如request.setAttribute("name","小强");
然后另一页面
String name=request.getAttribute("name");
name就是小强喽
getParameter()用来获得
如:www.111.com?id=xxx&passwd=xxx中的参数id和passwd
对于传入参数较少的请求比较好用
getAttribute()则更多用来获取封装后的数据,
再用封装数据的get()方法获得具体的单一属性值
getAttribute()是之前自己设定的
比如request.setAttribute("name","小强");
然后另一页面
String name=request.getAttribute("name");
name就是小强喽
getParameter()用来获得
如:www.111.com?id=xxx&passwd=xxx中的参数id和passwd
对于传入参数较少的请求比较好用
getAttribute()则更多用来获取封装后的数据,
再用封装数据的get()方法获得具体的单一属性值
本文解释了在Web开发中,如何使用request的getParameter方法来获取URL中的参数,以及getAttribute方法用于获取之前设置的属性值。这两种方法适用于不同的场景:getParameter适合处理简单的参数传递,而getAttribute则常用于获取封装后的数据。

被折叠的 条评论
为什么被折叠?



