如何在1个web.xml中定义2个servlet

时间:2013-11-02 04:11:52

标签: java xml tomcat servlets jersey

我尝试过thisthisthis。这些示例使用不同的框架。我正在使用Atmosphere + Jersey。我想知道如何在单个web.xml中配置2个servlet 修改 的web.xml

<servlet>
    <description>AtmosphereServlet</description>
    <servlet-name>AtmosphereServlet</servlet-name>
    <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>com.example.package1</param-value>
    </init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>AtmosphereServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
<servlet>
    <description>Admin</description>
    <servlet-name>Admin</servlet-name>
    <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>com.example.package2</param-value>
    </init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Admin</servlet-name>
    <url-pattern>/admin/*</url-pattern>
</servlet-mapping>

0 个答案:

没有答案