日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

jettytomcat对待表单过长问题

發布時間:2023/12/4 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 jettytomcat对待表单过长问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

為什么80%的碼農都做不了架構師?>>> ??

結論兩句話:

?

tomcat知道自己處理不了了,什么也不干過去了

jett知道自己處理不了了,拋個IllegalStateException出來通知一下

jetty默認允許的content-length=200×1000

org.eclipse.jetty.server.Request public void extractParameters(){if (_baseParameters == null) _baseParameters = new MultiMap(16);if (_paramsExtracted) {if (_parameters==null)_parameters=_baseParameters;return;}_paramsExtracted = true; ....// handle any _content.String encoding = getCharacterEncoding();String content_type = getContentType();if (content_type != null && content_type.length() > 0){content_type = HttpFields.valueParameters(content_type, null);if (MimeTypes.FORM_ENCODED.equalsIgnoreCase(content_type) &&(HttpMethods.POST.equals(getMethod()) || HttpMethods.PUT.equals(getMethod()))){int content_length = getContentLength();if (content_length != 0){try{int maxFormContentSize=-1;if (_context!=null)maxFormContentSize=_context.getContextHandler().getMaxFormContentSize();else{Integer size = (Integer)_connection.getConnector().getServer().getAttribute("org.eclipse.jetty.server.Request.maxFormContentSize");if (size!=null)maxFormContentSize =size.intValue();}if (content_length>maxFormContentSize && maxFormContentSize > 0){throw new IllegalStateException("Form too large"+content_length+">"+maxFormContentSize);}InputStream in = getInputStream();// Add form params to query paramsUrlEncoded.decodeTo(in, _baseParameters, encoding,content_length<0?maxFormContentSize:-1);}catch (IOException e){if (Log.isDebugEnabled())Log.warn(e);elseLog.warn(e.toString());}}}} ....} }

?

jetty修改content-length方法

?

<Configure id="Server" class="org.eclipse.jetty.server.Server"> ... <Call name="setAttribute"><Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg><Arg><SystemProperty name="org.eclipse.jetty.server.Request.maxFormContentSize" default="200000"/></Arg></Call> ... </Configure>

啟動方式

?

java -jar start.jar -Dorg.eclipse.jetty.server.Request.maxFormContentSize=600000

還有另外一種配置方式

?

<Call class="java.lang.System" name="setProperty"><Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg><Arg>400000</Arg> </Call> ?

tomcat默認允許的content-length=2×1024×1024

org.apache.catalina.connector.Request protected void parseParameters() { ......if (!("application/x-www-form-urlencoded".equals(contentType)))return;int len = getContentLength(); if (len > 0) {int maxPostSize = connector.getMaxPostSize(); // tomcat默認大小2*1024*1024 if ((maxPostSize > 0) && (len > maxPostSize)) {if (context.getLogger().isDebugEnabled()) {context.getLogger().debug(sm.getString("coyoteRequest.postTooLarge"));}return; // 內容超長則直接返回,jetty會拋出IllegalStateException//Parameters 對象沒有內容} ..... }public Map<String, String[]> getParameterMap() {if (parameterMap.isLocked())return parameterMap;Enumeration<String> enumeration = getParameterNames();while (enumeration.hasMoreElements()) {String name = enumeration.nextElement();String[] values = getParameterValues(name);parameterMap.put(name, values);}parameterMap.setLocked(true);return parameterMap; }public Enumeration<String> getParameterNames() {if (!parametersParsed)parseParameters();return coyoteRequest.getParameters().getParameterNames(); }

轉載于:https://my.oschina.net/boltwu/blog/533742

總結

以上是生活随笔為你收集整理的jettytomcat对待表单过长问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。