标签:标签 character play servlets exce enc png orb 其他
简单来说:文件服务器缺少允许文件读写的配置,直接跳到本帖下面web.xml文件部分,添加配置信息即可解决!
使用springmvc 跨服务器进行文件上传时出现错误:
409错误一般为文件服务器存放文件的目录结构不完整,找不到路径,需要自己进行目录结构完善和补全,即可排查错误。
403错误如下:
HTTP Status 500 – Internal Server Error
Type Exception Report
Message Request processing failed; nested exception is com.sun.jersey.api.client.UniformInterfaceException: PUT http://localhost:8081/uploads/2cc1ed31ffc1411d9d5808107ae28453_logo.png returned a response status of 403 Forbidden
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.sun.jersey.api.client.UniformInterfaceException: PUT http://localhost:8081/uploads/2cc1ed31ffc1411d9d5808107ae28453_logo.png returned a response status of 403 Forbidden
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:986)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:881)
javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
Root Cause
com.sun.jersey.api.client.UniformInterfaceException: PUT http://localhost:8081/uploads/2cc1ed31ffc1411d9d5808107ae28453_logo.png returned a response status of 403 Forbidden
因为所使用的文件服务器,单纯用来存储文件,还未进行其他配置,未配置支持文件写入所以出现问题。
网上搜索之后解决方式为在servlet标签下添加:
<init-param>
<param-name>readonly</param-name>
<param-value>false</param-value>
</init-param>
因为没有进行任何配置,连servlet标签都没有,无法直接添加,所以提供一个相对纯净的模板来提供tomcat服务器针对支持文件写入的配置
web.xml
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <!--suppress ALL --> <web-app> <display-name>Archetype Created Web Application</display-name> <servlet> <servlet-name>default</servlet-name> <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>readonly</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>listings</param-name> <param-value>false</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> </web-app>
添加之后,文件服务器进行正常工作,查看存放目录,文件均正常存储。
PUT 文件 returned a response status of 403 Forbidden
标签:标签 character play servlets exce enc png orb 其他
原文地址:https://www.cnblogs.com/STK0210/p/11216404.html