我使用Jersey进行restful service反序列化,并且在web.xml文件中声明我必须声明我的资源所在的包名。所以它最终在web.xml中看起来像这样:
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<!-- Register resources and providers under com.vogella.jersey.first package. -->
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<!-- this is my package name where my jersey resources are kept -->
<param-value>com.vogella.web.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>
现在我的问题是,如果我想在其他包中拥有泽西资源,我可以创建另一个web.xml文件或者它是如何完成的?
答案 0 :(得分:1)
包可以用逗号分隔列表。
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<!-- this is my package name where my jersey resources are kept -->
<param-value>com.vogella.web.resources, com.vogella.web.resources1</param-value>
</init-param>