Failed to parse multipart servlet request/The temporary upload location is not valid问题

版权声明:powered by 大狼狗郑锴/Moshow魔手 https://blog.csdn.net/moshowgame/article/details/82622546

问题背景

同事的springboot项目经常出现一个奇怪的问题Failed to parse multipart servlet request ; The temporary upload location is not valid,我的就不会。

    "message": "Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [C:\\Users\\Administrator\\AppData\\Local\\Temp\\tomcat.8761542752884705325.7777\\work\\Tomcat\\localhost\\ROOT] is not valid",
    "path": "/tcbj-yytsg-questionnaire/questionnaire/question/saveAnxietyDepression"

解决方案

网上的方案还是很不靠谱,有的说手工去加ROOT,这个确实能够解决,但是每隔几天就手工一下吗,不科学的。

当然,也有可能是linux目录权限不够,需要加下权限,剩下的,就是这个springboot的tomcat的设置问题了。

server:
  port: 5555
  servlet:
      context-path: /xxxx
  tomcat:
      remote-ip-header: x-forward-for
      uri-encoding: UTF-8
      max-threads: 1000
      max-http-header-size: 8096
      #核心代码,设置tomcat的basedir
      basedir: ${user.home}/tomcat/tmp

关于basedir,源码是这么解释的,Tomcat base directory. If not specified, a temporary directory is used.,也就是tomcat基础目录,如果没有指定,就用临时目录

/**
 * Tomcat base directory. If not specified, a temporary directory is used.
 */
private File basedir;

猜你喜欢

转载自blog.csdn.net/moshowgame/article/details/82622546