Difference between getAttribute() and getParameter()

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

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

10条回答
  •  礼貌的吻别
    2020-11-22 09:01

    Generally, a parameter is a string value that is most commonly known for being sent from the client to the server (e.g. a form post) and retrieved from the servlet request. The frustrating exception to this is ServletContext initial parameters which are string parameters that are configured in web.xml and exist on the server.

    An attribute is a server variable that exists within a specified scope i.e.:

    • application, available for the life of the entire application
    • session, available for the life of the session
    • request, only available for the life of the request
    • page (JSP only), available for the current JSP page only

提交回复
热议问题