Restful图片上传异常
我有一个安静的界面,如下所示。 我正在尝试使用 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 标头)。
我忘了写,我在 mvc 端使用 Springmvc,它可能与 spring mvc 块有关?
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);
}
When I request using this form
<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>
I get this error - The request sent by the client was syntactically incorrect (java.lang.RuntimeException: Could find no Content-Disposition header within part).
i forgot to write ,i use Springmvc at mvc side,it may be pertain spring mvc block?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
按以下方式更改 REST 服务签名可能会解决您的问题
Changing the REST service signature as the following may solve your problem