且构网

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

请求分派器转发和 servlet 链接之间的区别

更新时间:2023-12-04 10:48:16

没有什么不同.servlet 链接"只是在 servlet 过滤器不存在的黑暗 J2EE 1.1/1.2 时代创造的一个术语.实际上,这基本上是使用 RequestDispatcher#forward() 从一个 servlet 转发到另一个 servlet 的方法(并确保响应尚未提交,否则会导致 IllegalStateException代码>).

It's not different. "Servlet chaining" is just a term coined in dark J2EE 1.1/1.2 ages when servlet filters didn't exist. Indeed, it's basically the approach of using RequestDispatcher#forward() to forward from one to other servlet (and ensuring that the response isn't already committed as that would otherwise result in IllegalStateException).

自 J2EE 1.3(Servlet 2.3,十年之前!)servlet 过滤器a> 被引入,这使得这个过程变得更加干净和容易.从那时起,Servlet 链接"就受到了反对,并且通常被标记为糟糕的设计".如今,您最终只想得到一个前端控制器 servlet 和多种业务模型.

Since J2EE 1.3 (Servlet 2.3, over a decade ago already!) servlet filters were introduced which made the process so much more clean and easy. Since then, "Servlet chaining" is frowned upon and usually marked as "bad design". These days, you'd ultimately like to end up with only one front controller servlet and several business models.