[英]What happens when we add @GET and @Consumes on the same method
Is there any scenario or side-effect when we want to write write @javax.ws.rs.GET and @javax.ws.rs.Consumes at the same time on the same method? 当我们想同时使用同一方法编写@ javax.ws.rs.GET和@ javax.ws.rs.consums时,是否有任何场景或副作用?
Documentation for javax.ws.rsConsumes says "A container is responsible for ensuring that the method invoked is capable of consuming the media type of the HTTP request entity body" and GET does not have body, but using both annotations is allowed (ie no exception or any warning). javax.ws.rsConsumes的文档说:“容器负责确保所调用的方法能够使用HTTP请求实体主体的媒体类型”,而GET没有主体,但是允许使用两个注释(即,无例外)或任何警告)。
Oracle Doc's says 甲骨文医生说
The @Consumes annotation is used to specify the MIME media types of representations a resource can consume that were sent by the client. @Consumes批注用于指定客户端可以发送的资源可以使用的表示形式的MIME媒体类型。
Link to Documentation: click ! 链接到文档: 单击 !
I don't think that there is gonna be a side effect. 我认为不会有副作用。 Here's an example from the documentation: 这是文档中的示例:
@POST
@Consumes("text/plain")
public void postClichedMessage(String message) {
// Store the message
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.