问题:java.lang.IllegalArgumentException: This path does not exist (1135).

尝试解决方法一:试着输出上传的目的地址路径,如下图,然后按照该路径建立文件夹,之后再次调试就可正确上传

解决方法二:找到web.xml文件查找以下一段代码,注意这里有之前我调用函数时的name:“rootpath”,此时就知道了之前输出路径的来源,可在此修改为你所要上传位置的路径
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>PhotoUploadServlet</servlet-name>
<servlet-class>com.softeem.pp.servlet.PhotoUploadServlet</servlet-class>
<init-param>
<param-name>rootpath</param-name>
<param-value>E:\AlbumManage\web\photos\</param-value>
</init-param>
</servlet>

可参考这篇文章config.getInitParameter()调用后返回参数
中途改了上一问题解决方法二中所提的地址之后,不记得又改了什么,出现了rootpath=null的问题:com.jspsmart.upload.SmartUploadException: File can’t be saved (1120).最终我在file->project strustures->facets中删除了web项目,如何又重新添加之后发现恢复正常了。
为找到出错原因,我再次修改地址,如何重启Tomcat之后rootpath也随之改变,并未出现值为null的问题,所以我现在也不太清楚具体是什么导致值为null的。
本文探讨了Java中遇到的IllegalArgumentException:路径不存在的问题,通过输出路径、修改web.xml中初始化参数和Tomcat重启来解决。还提及了项目结构调整导致的问题及解决过程。
1万+

被折叠的 条评论
为什么被折叠?



