且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

每个路径一个Servlet或在一个Servlet中处理多个路径?

更新时间:2023-12-04 12:09:10

通常情况下,***解决方案取决于上下文和必须提供的功能. 我认为在大多数情况下,允许从单个servlet处理多个路径将更为有效,因为它只允许针对多个情况开发一个servlet. 在以下情况下,***将一组路径映射到单个servlet:

As it is often the case, what is best depends on the context and the functionality that must be offered. I would assume that in most cases allowing multiple paths to be handled from a single servlet would be more efficient as it allows the development of only one servlet for multiple cases. Mapping a group of paths to a single servlet would be preferable in the following cases:

  1. 这组路径提供的功能是相似的",可以由单个servlet处理,也许可以考虑实际路径.
  2. 应该提供的功能与用于调用servlet的实际路径无关.

不过,为每个servlet分配一个路径可能是有益的:

However it could be the cases that assigning a single path per servlet would be beneficial:

  1. servlet的功能应仅通过单个路径提供.
  2. 不同路径的功能不同,足以要求使用不同的Servlet类来实现它们.