我试图将文件上传到我的控制器。
这是我的控制器的上部。它一直有效,直到我达到 +- 2MB 的最大请求大小
> @RequestMapping(value = {"/runlocalfiles"}, method =
> RequestMethod.POST, produces = "application/json")
> @ResponseBody
> @CrossOrigin(origins = "http://localhost:4200")
> public ResponseEntity run( HttpServletRequest request) {
> String jsonBase64Files = request.getParameter("base64files");
> String jsonChecks = request.getParameter("checks");
浏览器中的错误消息:
> Failed to load http://localhost:5001/runlocalfiles: No
> 'Access-Control-Allow-Origin' header is present on the requested
> resource. Origin 'http://localhost:4200' is therefore not allowed
> access. The response had HTTP status code 500.
Java 控制台中的错误:
> java.lang.IllegalStateException: The multi-part request contained
> parameter data (excluding uploaded files) that exceeded the limit for
> maxPostSize set on the associated connector at
> org.apache.catalina.connector.Request.parseParts(Request.java:2893)
> ~[tomcat-embed-core-8.5.20.jar:8.5.20]...
我试图通过向 application.properties 添加新行来增加上传大小。还尝试将 -1 更改为例如 100MB
> spring.servlet.multipart.max-file-size= -1
> spring.servlet.multipart.max-request-size= -1
> spring.http.multipart.max-file-size = -1
> spring.http.multipart.max-request-size= -1
任何帮助都是有价值的。