宁静的图片上传例外 [英] restful image upload exception

查看:155
本文介绍了宁静的图片上传例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安静的界面,如下所示。
我正在尝试使用jaxrs界面上传图像,但我遇到了错误

I have a restful interface as shown below. I am trying to upload an image using jaxrs interface but I am faced with an error

    @POST
        @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
        @Path("createUserphotoDirectory/{userid}/{serverName}")
        @Consumes("multipart/form-data")
        public String createUserDirectory(@PathParam("userid") Long userid,
                   @PathParam("serverName") String serverName,
                   MultipartFormDataInput input) {
                System.out.println("1");
               photoService.createServerImages(userid,serverName,input);
               return responseMessageSource.getMessage("SUCCESSFULL_CRATED_ALBUM",null,null);
            }

当我请求使用此表格时

<html>
<body>
    <h1>JAX-RS Upload Form</h1>

    <form action="/AlbumApplication/rest/createUserphotoDirectory/1/FeedServer" method="post" enctype="multipart/form-data">

       <p>
        Select a file : <input type="file" name="uploadedFile" size="50" />
       </p>

       <input type="submit" value="Upload It" />
    </form>

</body>
</html>

我收到此错误 - 客户端发送的请求在语法上不正确( java.lang.RuntimeException:在部分内找不到Content-Disposition标头。)

I get this error - The request sent by the client was syntactically incorrect (java.lang.RuntimeException: Could find no Content-Disposition header within part).

我忘了写,我在mvc方面使用Springmvc,它可能属于spring mvc block?

i forgot to write ,i use Springmvc at mvc side,it may be pertain spring mvc block?

推荐答案

更改REST服务签名如下所示可以解决您的问题

Changing the REST service signature as the following may solve your problem

public String createUserDirectory(@PathParam("userid") Long userid,
         @PathParam("serverName") String serverName, 
         @FormDataParam("uploadedFile") File file,
         @FormDataParam("uploadedFile") FormDataContentDisposition disposition) {

这篇关于宁静的图片上传例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆