有什么区别getAttribute() and getParameter()内的方法HttpServletRequest class?
getAttribute()
getParameter()
HttpServletRequest
getParameter()返回http请求参数。这些从客户端传递到服务器。例如http://example.com/servlet?parameter=1。只能返回String
http://example.com/servlet?parameter=1
String
getAttribute()仅适用于服务器端 - 您可以使用可在同一请求中使用的属性填充请求。例如,您在 servlet 中设置一个属性,然后从 JSP 中读取它。可用于任何对象,而不仅仅是字符串。