4

我试过这个这个这个。这些示例使用不同的框架。我正在使用 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>
4

0 回答 0