宁静的图片上传例外

时间:2011-10-06 06:06:51

标签: java rest jersey jax-rs

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

    @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: Could find no Content-Disposition header within part).


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

1 个答案:

答案 0 :(得分:2)

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

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