Reputation: 1287
I am supposed to learn restful services using Java and JAX RS. I am trying to compile the following code, however I receive an error stating: annotation values must be of the form 'name=value'
.
The code is in principle correct, it is equivalent with http://www.vogella.com/tutorials/REST/article.html
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import javax.xml.ws.Response;
import java.io.IOException;
@Path("/")
public class WebResource {
@GET
@Produces(
MediaType.APPLICATION_XML,
MediaType.APPLICATION_ATOM_XML)
@XmlHeader("<?xml-stylesheet type='text/xsl' href='=static/styles/atom2html.xsl' ?>")
public Feed getFeed() {
return FeedController.getInstance().getFeed();
}
}
Upvotes: 2
Views: 4019
Reputation: 3885
OKAY: @RequestMapping( "/employees" )
OKAY: @RequestMapping( value = "/employees" )
OKAY: @RequestMapping( value = "/employees" method = RequestMethod.GET )
NO!!: @RequestMapping( "/employees" , method = RequestMethod.GET )
Basically, you can be implicit with the endpoint path (value) but once you have both a value and method, you need to be EXPLICIT.
I realize this is for spring... But this is where I ended up after 15+ minutes of looking all around the place for the solution to my error. And my error was :
annotation values must be of the form 'name=value'
Upvotes: 0
Reputation: 53819
You are providing several MediaType for the @Produces
annotation so you need to put them in an array:
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML})
Upvotes: 3