简体   繁体   English

如何使用Java在Rest Web Service中下载不同类型的文件

[英]how to download different type of files in rest web service using java

I want to download files which i wrote @POST method in rest web service using java. 我想下载使用Java在Rest Web Service中编写@POST方法的文件。 I used with FileIOStream, but i find that i can download images and zip file types,but file is corrupted. 我使用FileIOStream,但发现可以下载图像和zip文件类型,但是文件已损坏。 Do anyone know which library file i need to use in order to download all kinds of file types. 有谁知道我需要使用哪个库文件才能下载所有类型的文件。

Thanks. 谢谢。

You need to set the @Produces (or @Consumes) annotation to specify what type of data is being sent or received. 您需要设置@Produces(或@Consumes)注释以指定要发送或接收的数据类型。

@Consumes({"text/plain,text/html,application/zip"}) will allow a service to receive plain text, html and zip. @Consumes({“ text / plain,text / html,application / zip”})将允许服务接收纯文本,html和zip。

http://download.oracle.com/docs/cd/E19226-01/820-7627/gipxf/index.html http://download.oracle.com/docs/cd/E19226-01/820-7627/gipxf/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM