request.get Attributeとrequest.get Parameterの違い
HttpServletRequest getAttribute() , getParameter() , :
(1)HttpServletRequest setAttribute() , setParameter()
(2) Web , getParameter() , welcome.jsp authenticate.jsp ,welcome.jsp :
<a href="authenticate.jsp?username=weiqin">authenticate.jsp </a>
:
<form name="form1" method="post" action="authenticate.jsp">
:<input type="text" name="username">
<input type="submit" name="Submit" value=" ">
</form>
authenticate.jsp request.getParameter("username") username:
<% String username=request.getParameter("username"); %>
(3) Web , getAttribute() request 。 authenticate.jsp hello.jsp 。authenticate.jsp hello.jsp , ? authenticate.jsp setAttribute() :
<%
String username=request.getParameter("username");
request.setAttribute("username",username);
%>
<jsp:forward page="hello.jsp" />
hello.jsp getAttribute() :
<% String username=(String)request.getAttribute("username"); %>
Hello: <%=username %>
,request.getParameter() , Web Web , HTTP 。request.getParameter() String 。
request.setAttribute() getAttribute() Web , Web 。 Object 。
request.getAttribute() request , request.getParameter() http 。
string request.getParameter
request.getAttribute
,String