I'm pretty new with Java REST, I'm currently confused with the response I'm getting from POSTMAN or Chrome is always defaulted to XML and could not change it to JSON unless I remove the XML part. I'm using Jersey 2, Netbeans and Glassfish 4.1.1/4.1
This only returns XML
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
This will return JSON only
@GET
@Path("loc/{lat}/{long}")
@Produces({MediaType.APPLICATION_JSON})
@SuppressWarnings("unchecked")
//@Produces({MediaType.TEXT_PLAIN})
public List<Lastknown> findNearMeLastKnown(@PathParam("lat") String lat, @PathParam("long") String longitude) {
//List<Lastknown> results =;
return super.findNearMeLastKnown(lat,longitude);
}
A quick guess, you have to add the following header in POSTMAN:
Accept: application/json
Otherwise the server doesn't know which format you want....
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.