jersey中的 404 Not Found 错误。

 

 

jersey中的 404 Not Found 错误。

 

 

把资源定义到com.diandaxia.rest包里 就可以了:

 

jersey中的 404 Not Found 错误。

 

jersey中的 404 Not Found 错误。

 

 

当然也可以使用注册的方式,注册到jersey框架里。当一个类 必须再com.diandaxia.rest 包之外的话,又不想 扩大 自动扫描包范围,可以使用注册的方式。

public class RESTApplication extends ResourceConfig {

    public RESTApplication() {

        //想让jersey托管的部分需要加入扫描,或者使用register指定托管类也可以
        packages("com.haikong.resources","com.haikong.exception");
        //加载日志包
        register(LoggingFilter.class);
        //加载json转换器
        register(JacksonJsonProvider.class);
        System.out.println("加载RESTApplication");
    }
}

 

==================2017-02.16补充===============

 

原因2:<url-pattern>/webapi/*</url-pattern> 是针对项目而言的,过滤此项目的api请求,所以要http://localhost/项目/webapi/myresource 这样才行。

 

jersey中的 404 Not Found 错误。

 

相关文章:

  • 2022-12-23
  • 2021-07-16
  • 2021-10-28
  • 2022-01-02
  • 2021-04-01
  • 2022-12-23
  • 2021-10-06
  • 2022-12-23
猜你喜欢
  • 2021-11-16
  • 2021-07-31
  • 2021-10-18
  • 2022-01-01
  • 2021-10-01
  • 2021-09-22
  • 2021-05-20
相关资源
相似解决方案