[开发笔记] request 的 getAttribute() 与 getParameter() 用法及作用域

request.getAttribute() 指的是获取上个请求内的 setAttribute 的属性,作用域是单次的请求,而且只限于服务端。  从客户端的请求是无法获取到任何值的,因为客户端只是html 页面。

request.Parameter() 是获取客服端传递过来的属性,如页面的input属性 等。

 

 

另外有种情况,想在客户端保留request的 setAttribute 的属性 ,可以采用在服务端生成html 页面是 ,通过隐藏域的方式带到页面。

<input type = "hidden" name ="" value = "<%=request.getAttribute("xxx")%>"/>

之后可以在该页面再次提交时,在服务端通过 request.Parameter("xxx") 获取到该属性。

posted on 2017-03-06 16:38  黑鸟卫  阅读(435)  评论(0编辑  收藏  举报