一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

jsp request.getParameter()接受表单和url数据代码

时间:2022-06-29 02:39:38 编辑:袖梨 来源:一聚教程网

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等方式传入的数据

 

  

Request Information


        JSP request method: <%= request.getMethod() %>
       

        URL for the request: <%= request.getRequestURI() %>
       

        Protocol of the request: <%= request.getProtocol() %>
       

        Server name: <%= request.getServerName() %>
       

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

        Server port: <%= request.getServerPort() %>
       

        Remote address: <%= request.getRemoteAddr() %>
       

        Remote host: <%= request.getRemoteHost() %>
       

        Locale: <%= request.getLocale() %>
       

        User agent: <%= request.getHeader("User-Agent") %>


来自get 数据



Retrieving the Original URI



In ShowPath1.jsp教程:

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

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


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

热门栏目