jsp------request

3535 단어 htmljsp


1.request   HttpServletRequest       ,HttpServletRequest     ServletRequest,   ServletRequest       -----HttpServletRequest,            ,         Http  ,      ,       

request.getParameter(xx);//  (  /  )  

2.//    。。。。。。。。。。。。。。。。。。。。。。。。。。
  :input.jsp
<form method="post" action="input.jsp">
       :<input name="info"/>
  <input type="submit" value="  "/>
</form>

input.jsp
<%
   String str = request.getParameter("info"); //        ,  String  ,  Object  ,     
%>
 <h1>    <%=str%></h1>

   input.jsp     page  ,            ,      page  
  。。。  page     ,        ,      ,           ,          ,   request             

        

input.jsp
<%@page contentType="text/html;charset=GBK"%> // http          ,              ,   response.setContentType("text/html");  response.setCharacterEncoding("GBK");
<%
   String str = request.getParameter("info"); //              ,           iso-8859-1   ,     str   iso8859-1   ,      ,         ,      
//    ,       ,              ,         
str = new String(str.getBytes("ISO8859-1")); //   str = new String(str.getBytes("ISO8859-1"),"GBK");         page     

%>
 <h1>    <%=str%></h1>


         : ????       ,                
    :       ,        contentType,            --->    ,  ?????       



          。。。         
         ,       ServletRequest       :setCharacterEncoding()           

<%@page contentType="text/html;charset=GBK"%> ("text/html;charset=GBK");
<%
  request.setCharacterEncoding("GBK");//     
   String str = request.getParameter("info"); 
%>
 <h1>    <%=str%></h1>

3.   get post  
post         ,         ,           ,    HTTP        

XXX.jsp?   =   &   =      //        URL  

4.
public java.util.Enumeration getParameterNames();
         , jsp       ,     jsp       

Enumeration enur = request.getParameterNames();
while(enur.hasMoreElements()){
  String paramName = (String)enuc.nextElement();
}

              ,                   】

<form action="request04.jsp" method="post">
      : <input type="text" name="name"/><br/>
      :<input type="checkbox" name="**int" value="  ">  
          <input type="checkbox" name="**int" value="  ">  
          <input type="checkbox" name="**int" value="  ">  
</form>

          ,           "**"               

Enumeration enur = request.getParameterNames();
while(enur.hasMoreElements()){
  String paramName = (String)enuc.nextElement();
   if(paramName.startsWith("**")){
     String[]  paramValues = request.getParameterValues(paramName);
   }else{
    String  paramValue = request.getParameter(paramName);
    }
}

5.      ip  

request.getRemoteAddr();  //127.0.0.1










좋은 웹페이지 즐겨찾기