Servlet 与 MVC 框架

发布于 2024-08-25 18:02:18 字数 1435 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风向决定发型 2024-09-01 18:02:18

我将就此分享一些我的想法。

  1. 如上所述,这些框架是在 Servlet/JSP 之上开发的。
  2. 它们旨在避免代码重复(DRY)
  3. 框架基于设计模式 - 针对常见问题的通用可重用解决方案。
  4. 它们有助于在整个团队中轻松沟通,并使他们富有成效并专注于他们试图解决的企业级问题,而不是这些常见任务。
  5. 它们通过为众所周知的问题提供通用解决方案来帮助加速开发。 (例如表单验证、REST、测试、依赖项注入等)

当您开发大型企业应用程序并有多个开发人员处理它时,您肯定需要每个开发人员编写的项目/代码/结构具有一定的一致性。外部强制执行并不可靠,但当这些执行内置时,它有助于使项目易于维护、扩展,并且易于新人员在短时间内提高工作效率。

我相信这条规则不仅适用于 servlet-jsp,也适用于 JavaScript。在构建企业级 UI 时,仅使用本机 JavaScript 甚至低级 JavaScript API/库是不够的。要么采用最佳可用框架,要么抽象出共性并使其成为一个框架(而不是库)。

I will share some of my thoughts on this.

  1. As said above these frameworks are developed on top of Servlet/JSP.
  2. They are meant to avoid duplication of code (DRY).
  3. Framework are based on Design Patterns - general reusable solution for a commonly occurring problems.
  4. They help communicate the things easily across the team and make them productive and focused on the enterprise level problem they are trying to solve than these common tasks.
  5. They help in speeding up the development by providing general solution to commonly well known problems. (e.g. form validation, REST, testing, dependency injection etc.)

When you are developing large scale enterprise app and have multiple developers working on it, you definitely needs some uniformity across the project/code/structure each developer is writing. The enforcements forced externally are not reliable, but when those are in built it helps to make the project to be easy to maintain, scale and easy for new people to be productive with it within short time.

I believe this rule applies not just for servlet-jsp but for JavaScript as well. Just native JavaScript or even low level JavaScript API/Libraries are not enough when building an enterprise scale UI. Either adopt the Best available Framework or abstract out common nature and make it a framework (not library).

风透绣罗衣 2024-09-01 18:02:18

Spring MVC 仍然可以与 JSP 一起使用,其核心只是提供一个简单的调度程序 servlet,该 servlet 使用 Spring MVC 框架提供的机制(您可以在其中注册控制器等)。我想说这是为了方便,让事情更容易编写和维护。此外,您可以更轻松地对当前的开发做出反应(例如,RESTful 服务...您必须在 servlet 中手动编写所有这些内容)。最终这就是框架的用途。

Spring MVC still works with JSPs and in its core it provides nothing more than a simple dispatcher servlet that uses the mechanisms provided by the Spring MVC framework (where you register your controllers in etc.). I would say it is about convenience and making things a lot easier to write and maintain. Additionally you can react more easily to current developments (e.g. RESTful services... you would have to code all of it by hand in a servlet). In the end that is what frameworks are for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文