微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

webservice jersey 文件上传



webservice上传 在项目中整合spring可以使用


依赖这些 jar 包:
jersey-multipart-1.x.jar
mimepull-1.x.jar


@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)  // 消费注解必须是这个类型
@Produces(MediaType.APPLICATION_JSON)
public UploadRespBinding upload(FormDataMultiPart form,@Context HttpServletRequest request) {
    // FormDataBodyPart part = form.getField("photo");  // 获取 BodyPart
    // String filename = part.getContentdisposition().getFileName(); // 获取原始文件名
    // InputStream in = part.getValueAs(InputStream.class) // 转为 InputStream 之后你读吧
</pre><pre name="code" class="java">}


webservice上传 在项目中整合spring可以使用


@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)  // 消费注解必须是这个类型
@Produces(MediaType.APPLICATION_JSON)
public UploadRespBinding upload(FormDataMultiPart form,@Context HttpServletRequest request) {
    // FormDataBodyPart part = form.getField("photo");  // 获取 BodyPart
    // String filename = part.getContentdisposition().getFileName(); // 获取原始文件名
    // InputStream in = part.getValueAs(InputStream.class) // 转为 InputStream 之后你读吧
 
 
}

依赖这些 jar 包:

jersey-multipart-1.x.jar
mimepull-1.x.jar

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐