以前没有做笔记,现在项目中很多新同事又遇到这样的困惑,所以再整理一下:
getParameter返回String字符串
getParameter只能传递string类型的变量,
getParameter(),获取表单的值
getAttribute可以得到由setAttribute设置的参数值,就相当于是使用getAttribute得到一个自己定义
的参数,而不是从客户端得到的参数。
getAttribute是返回Object(对象),
getAttribute能传递vector,
getAttribute()获得session的值,
总的来说:request.getAttribute()方法返回request范围内存在的对象,而request.getParameter()方法是获取http提交过来的数据。
getParameter:获取post/get传递的参数值,在用表单或者url重定向传参数值时接收数据用的。获取某个表单传递上来的参数值。