使用web.xml配置Grizzly

时间:2012-01-24 19:45:01

标签: jersey web.xml grizzly

我可以使用以下几行来开始使用泽西网络服务并部署泽西网络服务。

protected HttpServer create() throws Throwable {
  ResourceConfig rc = new PackagesResourceConfig("com.resource", "com.provider");
  HttpServer server = GrizzlyServerFactory.createHttpServer(uri, rc);
  return server;
}

但有没有办法加载web.xml而不是ResourceConfig

<web-app>
  <servlet>
    <servlet-name>Jersey</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
      <param-name>com.sun.jersey.config.property.packages</param-name>
      <param-value>com.resource, com.provider</param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>Jersey</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>
</web-app>

0 个答案:

没有答案