在使用Jersey实现REST web service时,可以通过下面的方式指定多个包路径:
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.pack.first;com.pack.rest.second</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
或者
<!--配置Jersey RESTful服务-->
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>
com.demo1.resources
com.demo2.resources
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
即,你可以通过使用;
、,
、\n
等符号进行间隔多个包路径。