What problems should be paid attention to when uploading files by jarsey
This article mainly explains the "jarsey upload files need to pay attention to what problems", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "jarsey upload files need to pay attention to what problems" it!
Maven needs to be set up:
Org.glassfish.jersey.media
Jersey-media-multipart
2.7
Server side error: No injection source found for a parameter of type public javax.ws.rs.core.Response
Call the method register (MultiPartFeature.class) of ResourceConfig before starting
Class full path: org.glassfish.jersey.media.multipart.MultiPartFeature
The upload method definition:
@ POST@Consumes (MediaType.MULTIPART_FORM_DATA) public Response upload (@ FormDataParam ("file") InputStream fileInputStream, @ FormDataParam ("file") FormDataContentDisposition contentDispositionHeader) {
Some materials are written as: @ FormParam is wrong, guess is the use of previous versions.
These two classes are full paths.
Org.glassfish.jersey.media.multipart.FormDataParam
Org.glassfish.jersey.media.multipart.FormDataContentDisposition
Client error: MessageBodyWriter not found for media type
The client needs to call the register (MultiPartFeature.class) of the Client class before calling the target () method.
Thank you for your reading, the above is the content of "what problems do you need to pay attention to when uploading files on jarsey"? after the study of this article, I believe you have a deeper understanding of what problems you need to pay attention to when uploading files on jarsey, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!