Difference between getAttribute() and getParameter()

后端 未结 10 2261
情话喂你
情话喂你 2020-11-22 08:44

What is the difference between getAttribute() and getParameter() methods within HttpServletRequest class?

10条回答
  •  Happy的楠姐
    2020-11-22 09:03

    • getParameter() returns http request parameters. Those passed from the client to the server. For example http://example.com/servlet?parameter=1. Can only return String

    • getAttribute() is for server-side usage only - you fill the request with attributes that you can use within the same request. For example - you set an attribute in a servlet, and read it from a JSP. Can be used for any object, not just string.

提交回复
热议问题