Question

I am trying to pass parameter required in rest method via URL in Jersey+Spring.

this is my service class.

@Path("/find")
public class DownLoadService {

    @Autowired
    TransactionWork transactionDownload;

    @POST
    @Path("/bring")
    public Response GetFile(String uid) {
        String result = transactionDownload.BringFile(uid);
        return Response.status(200).entity(result).build();
    }

}

I am trying to access via URL

http://localhost:8080/ProjectName/rest/find/bring'parameter for method getFile??'

I don't know is it possible or not.

(I am using this first time may be silly question)

NOTE:I am accessing this service easily in servlet and working fine.

Était-ce utile?

La solution

After waiting for long I found this way

    @GET
    @Path("/bring/{withUID}")
    public Response GetFile(@PathParam("withUID") String uid) {
        String result = transactionDownload.BringFile(uid);
        return Response.status(200).entity(result).build();
    }

Now I am able to access the service in this way.

http://localhost:8080/RESTfulExample/rest/my/bring/AB
                                                   ^
                                                   parameter I passed to method

Ready to learn other way to do the same thing.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top