jsp request.getParameter()接受表單和url資料代碼

來源:互聯網
上載者:User

request.getParameter()方法傳遞的資料,會從Web用戶端傳到Web伺服器端,代表HTTP請求資料。request.getParameter()方法返回String類型的資料。

 

<%@ page import="java.util.*" %>
<%
   String title = "HttpServletRequest Method Values";
   Map entries = new TreeMap();
   entries.put("getCharacterEncoding", request.getCharacterEncoding());
   entries.put("getContentLength", "" + request.getContentLength());
   entries.put("getContentType", request.getContentType());
   entries.put("getLocale", request.getLocale());
   entries.put("getProtocol", request.getProtocol());
   entries.put("getRemoteAddr", request.getRemoteAddr());
   entries.put("getRemoteHost", request.getRemoteHost());
   entries.put("getScheme", request.getScheme());
   entries.put("getServerName", request.getServerName());
   entries.put("getServerPort", "" + request.getServerPort());
   entries.put("isSecure", "" + request.isSecure());
   request.setAttribute("_table_title", title);
   request.setAttribute("_table_entries", entries);
  
   out.println(request.getCharacterEncoding());
%>

request.getParameter()取得是通過容器的實現來取得通過類似post,get等方式傳入的資料

 

   <H1> Request Information </H1>
        JSP request method: <%= request.getMethod() %>
        <BR>
        URL for the request: <%= request.getRequestURI() %>
        <BR>
        Protocol of the request: <%= request.getProtocol() %>
        <BR>
        Server name: <%= request.getServerName() %>
        <BR>
        Path: <%= request.getServletPath() %>
        <BR>
        Server port: <%= request.getServerPort() %>
        <BR>
        Remote address: <%= request.getRemoteAddr() %>
        <BR>
        Remote host: <%= request.getRemoteHost() %>
        <BR>
        Locale: <%= request.getLocale() %>
        <BR>
        User agent: <%= request.getHeader("User-Agent") %>


來自get 資料

<html>
<head>
<title>Retrieving the Original URI</title>
</head>
<body>
<pre>
In ShowPath1.jsp教程:

   request.getRequestURI() =
      <%= request.getRequestURI() %>

   request.getServletPath() =
      <%= request.getServletPath() %>

</pre>
<jsp:include page="ShowPath2.jsp" flush="true"/>
</body>
</html>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.