gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 21:50:19 25 4
gpt4 key购买 nike

我已经尝试过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>

最佳答案

我正在执行Java编码我从未发现在单个web.xml文件中执行10个servlet的问题
并有共同点
     参见下面的代码示例

<servlet>
<servlet-name>jsrUploadFile</servlet-name>
<servlet-class>in.msedcl.se.jsrupload.JsrFileUpload</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>jsrUploadFile</servlet-name>
<url-pattern>/jsrUploadFile</url-pattern>
</servlet-mapping>


<servlet>
<servlet-name>installationUploadFiles</servlet-name>
<servlet-class>in.msedcl.se.installationFilesUpload.InstallationFilesUpload</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>installationUploadFiles</servlet-name>
<url-pattern>/installationUploadFiles</url-pattern>
</servlet-mapping>

关于java - 如何在1个web.xml中定义2个servlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19738874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com