关于黑马springmvc视频中的跨服务器传输报错问题解决

关于黑马springmvc视频中的跨服务器传输报错问题解决

严重: Servlet.service() for servlet [dispatcherServlet] in context with path [/springmvc-filesupload] threw exception
 [Request processing failed; nested exception is com.sun.jersey.api.client.UniformInterfaceException: PUT 
 http://localhost:8080/image_server_war/uploads/544386607c3e4990b3d73876c21c3599_话.txt returned a 
 response status of 400 Bad Request] with root cause
 com.sun.jersey.api.client.UniformInterfaceException:PUT
 http://localhost:8080/image_server_war/uploads/544386607c3e4990b3d73876c21c3599_话.txt returned a
 response status of 400 Bad Request

有些人日志文件可能会出现一个409的错误

运行环境

maven 3.6.3 
idea 2020.1.1
tomcat 8.5.5

原因1:

 maven在安装图片服务器项目的时候没有将webapp下的uploads文件安装进去
 (具体查询图片服务器中的target的WEB-INF同级目录是否有uploads文件夹)

原因2:

tomcat没有设置文件读写	 

解决方法:

首先,在tomcat的conf->web.xml找到servlet标签,在标签里添加如下代码,将tomcat设置为读写

<servlet>


	<init-param>
		<param-name>readonly</param-name>
		<param-value>false</param-value>
	</init-param>


</servlet>

然后,在tomcat->wabapps文件夹中找到自己项目的文件夹(项目必须先启动,不然tomcat不会生成该项目的文件夹)打开文件夹,找到WEB-INF文件夹,在他的同级目录下手动创建一个uploads文件夹

补充

我同样的项目在eclipce里面测试就不会出现这个问题,可能是插件的原因
貌似是maven管理项目生成target文件时候扫描不到wabapp包下WEB-INF包上的文件夹(文件可以扫描到)

猜你喜欢

转载自blog.csdn.net/qq_44769485/article/details/107961153