跨服务上传图片问题

2019-11-06  本文已影响0人  zackxizi

equest processing failed; nested exception is com.sun.jersey.api.client.UniformInterfaceException: PUT http://localhost:8081/fileuploadServer_war/uploads/9f7de25031f14079a4007e685e4c41b3-upload.jpg returned a response status of 403 Forbidden

原因:

tomcat默认的情况下是过滤到静态资源的上传的,所以需要我们手动的设置一下

解决思路

<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>listings</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
</servlet>
<init-param>
    <param-name>readonly</param-name>
    <param-value>false</param-value>
</init-param>
    <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>listings</param-name>
            <param-value>false</param-value>
        </init-param>
        
        <init-param>
        <param-name>readonly</param-name>
        <param-value>false</param-value>
       </init-param>

        <load-on-startup>1</load-on-startup>
    </servlet>

Request processing failed; nested exception is com.sun.jersey.api.client.UniformInterfaceException: PUT http://localhost:8081/fileuploadServer_war/uploads/2370dd3227b24a65b155e6baff4e63ab-upload.jpg returned a response status of 409 Conflict

原因:

1.打包路径下没有对应的uploads路径,需要在打包的文件夹内创建uploads
一般打包路径在 tomcat安装路径下:apache-tomcat-8.5.42/webapps/你的项目


image.png
  1. 确保 保存图片的服务是启动的
上一篇下一篇

猜你喜欢

热点阅读