JSP 到 Servlet 的关系 [英] JSP to Servlet Relation
问题描述
书籍和互联网上有很多关于如何将 Servlet 用作 JSP 的示例.但我想知道使用它们的最佳方法是什么,同时考虑到良好的架构.
There are many, many examples in books, and on the internet about how to use Servlets as JSPs. But I would like to know what the best way to go about using them, with a mind to good architecture.
Servlet 和 JSP 是否应该是一对一的关系?表现得像 ASP.NET代码隐藏"页面?
Should there be a one-to-one relation of Servlets to JSPs? Acting like ASP.NET "Code-Behind" pages?
或者更像 ASP.NET MVC,用一个 Servlet 控制多个动作,并转发到多个视图?
Or more like ASP.NET MVC, with a single Servlet controlling multiple actions, and forwarding to multiple views?
这是一个关于纯 Java EE 开发的问题.请不要简单地建议另一个框架.
This is a question regarding pure Java EE development. Please don't simply suggest another framework.
推荐答案
这个怎么样?我在学校的一个项目中做了这个:
How about this? I made this in one of my school projects:
替代文字 http://img576.imageshack.us/img576/3064/mvci.jpg
这是我根据我对 servlet 和 JSP 的理解做出的假设.我很乐意听取您的意见和想法来改进这一点.
This was my assumption based on my understanding of servlets and JSP. I would love to have your comments and ideas to improve this.
这篇关于JSP 到 Servlet 的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!