您的位置:首页 > 大数据 > 人工智能

因为缺失POST GET注解而导致Failed processing arguments of org.jboss.resteasy.spi.metadata.ResourceLocator

2017-05-31 15:07 716 查看
面向服务的架构现在如火如荼,国内常用的当属阿里巴巴开源的dubbo,但我觉得后起之秀的spring cloud很可能弯道超车。闲话说了一些,下面入主题,出问题rest服务接口

    @Path("queryList")

    //@POST---漏掉@POST注解就会出错

    @Override

下面来分析下POST注解:

@Target({ElementType.METHOD})

@Retention(RetentionPolicy.RUNTIME)

@HttpMethod(HttpMethod.POST)

@Documented

public @interface POST {

}

这个里面又涉及到一个主要的注解HttpMethod:

/**

 * Associates the name of a HTTP method with an annotation. A Java method annotated

 * with a runtime annotation that is itself annotated with this annotation will

 * be used to handle HTTP requests of the indicated HTTP method
. It is an error

 * for a method to be annotated with more than one annotation that is annotated

 * with {@code HttpMethod}.

 *

 * @author Paul Sandoz

 * @author Marc Hadley

 * @see GET

 * @see POST

 * @see PUT

 * @see DELETE

 * @see HEAD

 * @since 1.0

 */

@Target({ElementType.ANNOTATION_TYPE})

@Retention(RetentionPolicy.RUNTIME)

@Documented

public @interface HttpMethod

该接口doc说明概括下来就是:

HttpMethod(或者扩展注解接口)注解的方法会被用来处理相应HTTP请求方法(POST/GET/PUT等)请求,如果漏掉这个注解,那么相应的方法就没有了这个能力!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐