为什么 Spring 有 taglibs 和 taglibs?速度/freemarker 宏?这不是反弹簧吗?
我是 Spring 的新手,据我了解,Spring 的教条是让您的应用程序尽可能少地依赖框架。每当我看到一些文档或注释要求你的类了解 spring 框架时,它总是附带一个免责声明,表明该方法本质上是反 spring 的。
所以我的好奇心想知道为什么有 spring 特定的标签库和等效的速度/freemarker 宏用于绑定、表单构建和验证?通过这样做,您将视图层的大部分与 Spring 框架紧密联系在一起。
这不是反弹簧吗?
I'm new to Spring, and the Spring dogma, as I understand it, is to make your applications as least-reliant on the framework as possible. Any time I see some documentation or note that requires that your class be aware of the spring framework it always comes with a disclaimer that says that the approach is anti-spring in nature.
So my uninitiated curiosity wonders why have spring specific tag-libs and the equivelent velocity/freemarker macros for binding, form building, and validation? By doing this you are closely tying large chunks of your view layer to the Spring framework.
Isn't this anti-spring-like?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然,这是一个选择。无论是在软件中还是在生活中,都要警惕绝对和教条。
Spring 内置了很多依赖项。接受他们。
Spring所做的就是给你很多选择。当您选择使用 JSP 或 Velocity 等常用技术时,Spring 会提供出色的支持。如果您不想依赖其中任何一个,请务必使用原始 HTML、CSS 和 JavaScript 来编写 UI。这是你的选择。 Spring 没有强制执行任何事情。
我认为批评没有道理。 Spring 允许您使用 JDBC 或 Hibernate。依赖 Hibernate 是错误的吗?如果您说是,请不要使用它。这是你的选择。
更新:
如果您想要一种正确的方式处理所有事情,请尝试 Grails。它基于 Spring 和 Hibernate。很多选择都是为你做的。它类似于 Ruby on Rails,只不过它使用 Java、Groovy、Spring 和 Hibernate。
It's a choice, of course. Be wary of absolutes and dogma, both in software and in life.
Spring has lots of dependencies built-in. Accept them.
What Spring does is give you a lot of choices. When you choose to use common technologies like JSP or Velocity, Spring offers excellent support. If you don't want to rely on either one, by all means write your UI in terms of raw HTML, CSS, and JavaScript. It's your choice. Spring doesn't mandate anything.
I don't think the criticism is valid. Spring lets you use either JDBC or Hibernate. Is it wrong to have a dependency on Hibernate? If you say yes, don't use it. It's your choice.
UPDATE:
If you want one right way with everything, try Grails. It's based on Spring and Hibernate. A lot of the choices are made for you. It's like Ruby on Rails, except it uses Java, Groovy, Spring, and Hibernate.