Difference between getAttribute() and getParameter()

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

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

10条回答
  •  不要未来只要你来
    2020-11-22 09:14

    It is crucial to know that attributes are not parameters.

    The return type for attributes is an Object, whereas the return type for a parameter is a String. When calling the getAttribute(String name) method, bear in mind that the attributes must be cast.

    Additionally, there is no servlet specific attributes, and there are no session parameters.

    This post is written with the purpose to connect on @Bozho's response, as additional information that can be useful for other people.

提交回复
热议问题