您可以使用一些JAX-RS库,例如Apache Wink,因此可以编写如下代码:
@Path("/upload")class UploadResource { @POST @Consumes(MediaType.APPLICATION_OCTET_STREAM) public Response upload(byte[] input) { // store input somewhere return Response.ok().build(); }}这样您将收到文件是
byte[]。您还可以作为InputStream接收:
@Path("/upload")class UploadResource { @POST @Consumes(MediaType.APPLICATION_OCTET_STREAM) public Response upload(InputStream input) { // store input somewhere return Response.ok().build(); }}


