JAX RS MediaType annotation values must be of the form 'name=value'

自古美人都是妖i 提交于 2019-12-24 08:13:41

问题


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();
    }
}

回答1:


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})


来源:https://stackoverflow.com/questions/24352048/jax-rs-mediatype-annotation-values-must-be-of-the-form-name-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!