Spring MVC 是 Servlet/JSP/Beans MVC 模型的替代品吗
我为这个问题的“新手”表示歉意,但我最近一直在研究 JSP/Servlet,我将主要使用它们来构建 Web 应用程序/动态网站。我非常喜欢这样的设计模式:使用 servlet 来完成业务逻辑(代码),使用 jsp 来设计和显示,使用 beans 来显示 jsp 页面中的动态内容。
我读了很多关于 Spring MVC 的文章,但我很困惑它是否是我刚刚描述的设计模型的替代品,或者它是否更适合桌面 Java 应用程序或其他东西。
任何见解或建议都会受到好评。
I apologize for the "noobness" of this question, but I've recently been studing JSP/Servlets that I will be using primarily to build web applications/dynamic websites. I really like the design model of using servlets to do the business logic (code), jsp to design and display, and beans to display the dynamic content in the jsp page.
I've been reading a lot about Spring MVC and i'm confused on whether or not its a replacement for the design model I just described, or is it geared more towards desktop java apps or perhaps something else.
Any insight or advice would be well received.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上这两个是完全不同的。使用 JSP 和 servlet 的 Java 方式是 Model2 范例,其中 JSP 作为视图,servlet 作为控制器,标准 Java bean 作为模型。 MVC 是一个更全面的范例,您仍然有一个模型、一个视图和一个控制器,但它们并不分别是 Java bean、JSP 和 servlet。 Spring MVC 提供了一个很好的范例实现,允许您拥有任何您想要的控制器,除了 JSP 之外的多种技术作为视图,并且该模型也非常自由。另外,除了 MVC 之外,它还为您提供了很多额外的东西,例如创建向导的能力等。
Actually those 2 are quite different. The Java way of using JSPs and servlets is the Model2 paradigm, in which you'd have you JSP as views, your servlets as controllers and standard Java beans as models. MVC is a more comprehensive paradigm, you still have a model a view and a controller but they're not stuck to being Java beans, JSPs and servlets respectivelly. Spring MVC offers a nice implemententation of the paradigm, allowing you to have whatever you want as controller, multiple technologies besides JSP as views, and the model is pretty free too. Plus it gives you a lot of extra stuff besides the MVC, like the abiltity to make wizards, etc.
Spring MVC 框架提供了丰富的功能来构建健壮的 Web 应用程序。
它的 MVC 建模并充当 servlet 的包装器,提供简洁易用的界面。
所有接口都与 Servlet API 紧密耦合。这种耦合确保了 Servlet API 的功能仍然可供开发人员使用,同时提供高度抽象框架以方便使用所述 API。
与它捆绑在一起的还有 bean 模型。
您仍然可以使用 JSP 作为 Spring MVC 的视图层,因为它没有自己的视图语言。
它提供了速度、自由标记等选项。
更多信息@ http://static.springsource。 org/spring/docs/current/spring-framework-reference/html/mvc.html
Spring MVC framework provides rich functionality for building robust Web Applications.
Its MVC modeled and acts as an wrapper over servlets, providing a neat easy to use interface.
All interfaces are tightly coupled to the Servlet API. This coupling makes sure that the features of the Servlet API remain available to developers while offering a high abstraction framework to ease working with said API.
Also bundled with it is the bean model.
You can still use JSP as the view layer with Spring MVC, as it does not have its own view language.
It provides option for velocity, freemarker and much more.
More info @ http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html
Spring 的一部分是一个 Web 框架,尽管 Spring 也可以用于非 Web 应用程序。它绝对可以替代您所描述的内容,但它也可以有更多功能。我鼓励您阅读 Spring 文档 http://docs .spring.io/spring/docs/current/spring-framework-reference/html/
A portion of Spring is a web framework, though Spring can also be used for non-web apps. It can definitely be a replacement for what you desribed, but it can also be so much more. I encourage you to read the spring docs at http://docs.spring.io/spring/docs/current/spring-framework-reference/html/