org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException the request was rejected because its size (91463901) exceeds the configured maximum (2097152)[转载] 2009-02-26 22:08:14| 分类: struts2 | 标签: |字号大中小 订阅 .
在上传94M的视频出现异常如下:
[@APPNAME@] ERROR [http-80-3] MultiPartRequest.parse(130) |
org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected
because its size (102147245) exceeds the configured maximum (50097152)
[@APPNAME@] ERROR [http-80-3] FileUploadInterceptor.intercept(227) | the request was rejected
because its size (102147245) exceeds the configured maximum (50097152)
解析:这个最大值是在struts2的源文件“struts2-core-2.0.11.1.jar\org\apache\struts\
default.properties”中的struts.multipart.maxSize=2097152语句,如果想改大的话,就重新设定它,有两种
方法:
一种是重写:struts.properties文件。
二是在struts.xml中加入常量来改变它如“ Java代码
<constant name="struts.multipart.maxSize" value="10000000" />
当然了,也有struts2的拦截器可以限制文件的类型、大小等,但是当上传文件大小2M后,这个拦截器就不起作用
了,只用小于2M(默认大小)的时候才起作用。那是因为:common-fileupload组件默认最大支持上传文件的大小
为2M,当我们上传大于2M的文件时,就会出现上面所说的异常。是这个异常的发生导致了fileUpload拦截器没有机
会执行,所以看到的是页面没有任何变化,也没有任何提示信息,只是在控制台打印出了上面的那些上传文件过
大的异常。
我解决问题的过程:
刚开始只是在struts.xml文件最上部加入
<constant name="struts.multipart.maxSize" value="1000000000" />
但还是报同样的错误。
接着查看struts.properties文件里的配置为:
### Load custom default resource bundles
struts.custom.i18n.resources=MessageResource
struts.multipart.maxSize=50097152
### character encoding
struts.i18n.encoding=GBK
修改为
### Load custom default resource bundles
struts.custom.i18n.resources=MessageResource
struts.multipart.maxSize=1000000000
### character encoding
struts.i18n.encoding=GBK
分享到:
相关推荐
import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.log4j.Logger; public class FileServlet extends ...
import org.apache.commons.fileupload.disk.DiskFileItemFactory; public class FileUpload extends HttpServlet { private String uploadPath = ""; // 用于存放上传文件的目录 private File tempPath = new ...
SpringMVC在内部集成了Apache Commons FileUpload,所以我们可以直接使用`@RequestParam("file") MultipartFile file`这样的注解来接收上传的文件。在处理这个参数时,我们需要确保文件有效并将其保存到服务器的某个...
源文件:commons-fileupload-1.4.jar 目的:tomcat10版本导致List<FileItem> fileItems = sfu.parseRequest(request) 入参的HttpServletRequest必须为:import jakarta.servlet.http.HttpServletRequest; 运行cmd,...
import org.apache.commons.fileupload.servlet.ServletFileUpload; public class UploadAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest ...
**Apache Commons FileUpload** (commons-fileupload-1.3.2.jar) Apache Commons FileUpload是一个专门处理HTTP请求中的多部分数据(multipart/form-data)的库,这是HTML表单上传文件时使用的标准格式。该库解析...
import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; // ... public class UploadAction extends Action { public ActionForward...
import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.disk.DiskFileItemFactory;...
<%@ page import="org.apache.commons.fileupload.*" %> <%@ page import="java.util.*" %> <%@ page import="java.io.*" %> try { String dir = request.getRealPath("."); DiskFileUpload fu = new ...
- `commons-fileupload.jar`(用于文件上传) - `commons-logging.jar` - `commons-validator.jar` - `jakarta-oro.jar` - `struts.jar` 这些库可以确保Struts框架正常运行并支持文件上传功能。 #### 2. 配置...
- commons-fileupload-1.2.2.jar #### 三、关键配置文件内容 1. **web.xml文件配置** ```xml <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...
在Java的Web开发中,处理文件上传和下载是常见的需求,Apache Commons FileUpload库就是用于处理这类任务的强大工具。这个库使得我们能够方便地在Servlet环境中处理multipart/form-data类型的请求,这种请求类型常...
- commons-fileupload-1.2.1.jar - commons-logging-1.0.4.jar - freemarker-2.3.13.jar - ognl-2.6.11.jar - struts2-core-2.1.6.jar - xwork-2.1.2.jar - **Spring2.5.6相关jar包:** - spring.jar (包含...
import org.apache.commons.fileupload.FileUploadBase.SizeLimitExceededException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet....
import org.apache.commons.fileupload.servlet.ServletFileUpload; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.io.IOException; import java.util.List; public class ...
- `commons-fileupload-1.2.2.jar` - `commons-io-2.0.1.jar` - `commons-logging-1.1.1.jar` - `ognl-3.0.1.jar` - `struts2-core-2.2.3.jar` - `xwork-core-2.2.3.jar` - 除了以上基本的Struts2.0所需库...
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> <param-name>config</param-name> <param-value>struts-default.xml,config/struts/struts...
import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; public class UploadServlet extends HttpServlet { private static final ...