当前位置: 首页 > 知识库问答 >
问题:

无法解析多部分servlet请求

阎单鹗
2023-03-14

当我尝试用我的代码下载文件时,我出现了这样的错误:

HTTP状态500-请求处理失败;嵌套异常是org.springframework.web.multipart.multipartException:无法解析多部分servlet请求;嵌套异常是java.io.ioException:临时上载位置[/tmp/tomcat.5139949927832460132.8080/work/tomcat/localhost/root]无效

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.5139949927832460132.8080/work/Tomcat/localhost/ROOT] is not valid
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:105)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:107)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
root cause

org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.5139949927832460132.8080/work/Tomcat/localhost/ROOT] is not valid
    org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:111)
    org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:85)
    org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:76)
    org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1099)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:932)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:105)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:107)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
root cause

java.io.IOException: The temporary upload location [/tmp/tomcat.5139949927832460132.8080/work/Tomcat/localhost/ROOT] is not valid
    org.apache.catalina.connector.Request.parseParts(Request.java:2776)
    org.apache.catalina.connector.Request.parseParameters(Request.java:3176)
    org.apache.catalina.connector.Request.getParameter(Request.java:1110)
    org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:381)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:70)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:107)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

提前感谢!

共有1个答案

暴才俊
2023-03-14

您可以通过修改start.sh脚本来指定重写/tmp文件夹:

jvm_options=“-xrs-xms256m-xmx512m-djava.io.tmpdir=/opt/tridion/deployer-live/tmp”前三个选项(-xrs-xms256m-xmx512m)是开箱即用的,我只是添加了“-djava.io.tmpdir=/opt/tridion/deployer-live/tmp”。

tomcat主文件夹和docbase文件夹现在在我指定的位置创建,清理脚本不再有任何危害。

学分@quirijn

 类似资料:
  • 我正在使用Spring Boot(1.5.7)和ng2文件上传(1.2.1)将文件上传到服务器。 所以我遇到了下一个问题,当文件上传开始并中断时(例如关闭浏览器选项卡),Spring Boot会记录下一个错误(两次): 当我将@ExceptionHandler添加到@ControllerAdvice时: 和应用程序的下一个属性。属性: 现在,当文件上载中断时,@ExceptionHandler会按

  • 我正在使用Multipart执行帖子类型请求。问题是因为我一直收到两个错误 1) 500 2) 422不可处理实体 Api仅接受音乐文件。因此,我添加了一个默认文件,以避免不断选择新文件 和我的界面 如果有任何帮助,我将不胜感激。 我发现它将文件作为对象通过Reform2发送到服务器

  • 我已经用Spring Initializr创建了一个Spring Boot 2演示应用程序,并在下面添加了控制器: 然后,我添加了一个包含此配置的应用程序.yaml 文件: 我的目标是让控制器在开始读取< code>payload文件之前解析并记录< code>metadata文件,但是< code > resolve-lazyly 设置似乎被Boot忽略了:控制器内部的代码在整个主体被读取之前不

  • 我正在使用请求库编写Web服务客户端。我正在获取包含文件和文本json的多部分/表单数据。我不知道如何解析它。是否有合适的库来解析python中的多部分/表单数据格式,或者我应该自己编写解析器? 我的代码: b'\r\n--c00750d1-8ce4-4d29-8390-b50bf02a92cc\r\nContent-Displace: form-data; name="playback Hash

  • 我无法在servlet多部分发布期间访问Spring Security信息。Spring Security信息在常规get和post方法中可用,但对于多部分post方法不可用。我试图直接通过SecurityContextHolder.getContext().getAuthentication()和通过一个访问SecurityContextHolder.getContext().getAuthen

  • 问题内容: 我正在使用请求库编写Web Service客户端。我正在包含文件和text-json的multipart / form- data中获取数据。我不知道如何解析它。是否有合适的库可以解析python中的multipart / form-data格式,还是我应该自己编写解析器? 我的代码: b’\ r \ n–c00750d1-8ce4-4d29-8390-b50bf02a92cc \ r