HTTP Get请求URL最大长度

各浏览器HTTP Get请求URL最大长度并不相同,几类常用浏览器最大长度及超过最大长度后提交情况如下:

IE6.0                :url最大长度2083个字符,超过最大长度后无法提交。
IE7.0                :url最大长度2083个字符,超过最大长度后仍然能提交,但是只能传过去2083个字符。
firefox 3.0.3     :url最大长度7764个字符,超过最大长度后无法提交。
Opera 9.52       :url最大长度7648个字符,超过最大长度后无法提交。
Google Chrome 2.0.168   :url最大长度7713个字符,超过最大长度后无法提交。

 

注:我的url为http://192.168.6.75:6060/web/urlServlet?m=

 

微软官方说明见>>

 

测试代码如下:

urlget.jsp源代码:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>url get test!</title> </head> <body> <% StringBuffer message = new StringBuffer(); for(int i=1;i<=2041;i++){ if(i%2==0){ message.append("$"); }else{ message.append("@"); } } System.out.println("客户端(message长度):"+message.length()); System.out.println("客户端(message内容):"+message); %> <form action="urlServlet" method="post"> Post提交:<input type="text" value="<%=message%>" name="m"> <input type="submit" value="提交"> </form> Get提交:<a href="urlServlet?m=<%=message %>">urlServlet</a> </body> </html>

URLServlet.java源代码:
package com.ctcmctv.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class URLServlet extends HttpServlet { /** * Constructor of the object. */ public URLServlet() { super(); } public void init() throws ServletException { System.out.println("URLServlet-init"); } public void destroy() { System.out.println("URLServlet-destroy"); } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("服务器端-doGet"); request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); String message = request.getParameter("m"); PrintWriter out = response.getWriter(); out.println("服务器端-doGet处理结果:"+"<br>"); out.println("message长度:" + message.length()+"<br>"); out.println("message内容:<hr>" + message); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("服务器端-doPost"); request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); String message = request.getParameter("m"); PrintWriter out = response.getWriter(); out.println("服务器端-doPost处理结果:"+"<br>"); out.println("message长度:" + message.length()+"<br>"); out.println("message内容:<hr>" + message); } }

你可能感兴趣的:(html,String,浏览器,服务器,url,Constructor)