美文网首页
跨服务上传图片问题

跨服务上传图片问题

作者: zackxizi | 来源:发表于2019-11-06 02:15 被阅读0次

    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默认的情况下是过滤到静态资源的上传的,所以需要我们手动的设置一下

    解决思路

    • 打开你的tomcat的安装的路径,点击conf,找到web.xml打开,然后搜索DefaultServlet
    <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>
    
    • tomcat默认情况下是只读的,如果我们要往里边上传东西,是要将只读改为false的,加上下面的代码就可以了!
    <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. 确保 保存图片的服务是启动的

    相关文章

      网友评论

          本文标题:跨服务上传图片问题

          本文链接:https://www.haomeiwen.com/subject/rpeybctx.html