I have a problem producing JSON in my application.
I'm trying a tutorial about Consuming Java Restful Web Service with AngularJS. I've created a dynamic web project as my RESTful server and then added the following libraries:
Here is the service :
package ws;
import java.awt.PageAttributes.MediaType;
import java.util.*;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import entities.Prospect;
@Path("prospect")
public class ProspectRestful {
@GET
@Path("findall")
@Produces(MediaType.APPLICATION_JSON)
public List<Prospect> findAll(){
List<Prospect> result = new ArrayList<Prospect>();
result.add(new Prospect(35, "Name 35", "last35"));
result.add(new Prospect(36, "Name 36", "last36"));
return result;
}
}
But I'm getting this error:
APPLICATION_JSON cannot be resolved or is not a field.
I've seen in another question that jersey-media-json-jettison-2.4.jar should be there so I added it but no sign.
I'm sure I'm not using a Maven project, in the same tutorial they didn't use Maven either.
Remove this
import java.awt.PageAttributes.MediaType;
and add this
import javax.ws.rs.core.MediaType;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With