JAX RS MediaType批注值的格式必须为“名称=值" [英] JAX RS MediaType annotation values must be of the form 'name=value'
本文介绍了JAX RS MediaType批注值的格式必须为“名称=值"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该使用Java和JAX RS学习宁静的服务.我正在尝试编译以下代码,但是我收到一条错误消息:annotation values must be of the form 'name=value'
.
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'
.
该代码原则上是正确的,它等效于 http://www.vogella .com/tutorials/REST/article.html
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();
}
}
推荐答案
您要为@Produces
批注提供几种MediaType,因此需要将它们放入数组中:
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})
这篇关于JAX RS MediaType批注值的格式必须为“名称=值"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文