本文介绍了System.Web.HttpException:超出最大请求长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我超越了异常。我尝试了很多来自SO的解决方案,但这些解决方案都不起作用,因为大多数解决方案都是针对 asp.net

I am getting above exception. I have tried many solutions from SO, which didn't work, because most of them are for asp.net.

这是我的网络应用程序的 web.xml 的一部分:

This is part of web.xml of my web app:

<servlet>
    <servlet-name>MainPageServlet</servlet-name>
    <servlet-class>servlets.MainPageServlet</servlet-class>
    <multipart-config>
        <!-- 10MB of files -->
        <max-file-size>10485760B</max-file-size>
        <!-- 10KB of form data -->
        <max-request-size>10240B</max-request-size>
        <!-- Buffer to disk over 512KB -->
        <file-size-threshold>524288B</file-size-threshold>
    </multipart-config>
</servlet>
<servlet-mapping>
    <servlet-name>MainPageServlet</servlet-name>
    <url-pattern>/mainPage/*</url-pattern>
</servlet-mapping>

这是我得到的错误(在 http post 文件上传):

This is the error I am getting(in a browser after http post file upload):

   [HttpException (0x80004005): Maximum request length exceeded.]
   System.Web.HttpRequest.GetEntireRawContent() +9685979
   System.Web.HttpRequest.get_InputStream() +41
   Caucho.IIS.ResinHandler.DoHmux(HttpContext context) +138
   Caucho.IIS.ResinHandler.ProcessRequest(HttpContext context) +334
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

该文件 5,2Mb

知道我应该在哪里设置最大文件大小?正如你在web.xml中设置的那样,你可能会发现它不起作用。

Any idea where should I set up the max file size? As you may see it doesn't work if I set it in the web.xml.

我正在使用 resin java服务器。

I am using resin java server.

当我在大小值java IDE抱怨后添加'B'为 Bytes 时。但是,如果它不存在,我收到此错误:

Also when I add 'B' as Bytes after the size value java IDE complains. However, if it isn't there, I am getting this error:

500 Servlet exception
WEB-INF/web.xml:29: com.caucho.server.dispatch.MultipartConfigImpl.setMaxFileSize():
com.caucho.config.types.Bytes.addText(): byte-valued expression `10485760'
must have units.  '16B' for bytes, '16K' for kilobytes, '16M' for megabytes,
'16G' for gigabytes.


推荐答案

max-request-size不是表单的最大大小数据,它是整个上传请求的最大大小。

max-request-size is not max size of form data, it's the max size of the whole upload request.

看看:

17.11.1

Take a look:https://docs.oracle.com/javaee/7/tutorial/servlets011.htm17.11.1

在您的情况下,使max-request-size大于5.2MB

In your case, make max-request-size larger than 5.2MB

这篇关于System.Web.HttpException:超出最大请求长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 08:57