简体   繁体   English

为什么Spring有taglibs和velocity / freemarker宏? 那不是反弹簧吗?

[英]Why does Spring have taglibs & velocity/freemarker macros? Isn't that anti-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. 我是Spring的新手,正如我所理解的那样,Spring的教条就是让你的应用程序尽可能地依赖于框架。 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. 通过这样做,您将视图层的大块紧密绑定到Spring框架。

Isn't this anti-spring-like? 这不是反弹簧吗?

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. Spring内置了很多依赖项。 Accept them. 接受他们。

What Spring does is give you a lot of choices. Spring做的是给你很多选择。 When you choose to use common technologies like JSP or Velocity, Spring offers excellent support. 当您选择使用JSP或Velocity等常用技术时,Spring提供了出色的支持。 If you don't want to rely on either one, by all means write your UI in terms of raw HTML, CSS, and JavaScript. 如果您不想依赖任何一个,请务必根据原始HTML,CSS和JavaScript编写UI。 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. Spring允许您使用JDBC或Hibernate。 Is it wrong to have a dependency on Hibernate? 依赖Hibernate是错误的吗? If you say yes, don't use it. 如果您说是,请不要使用它。 It's your choice. 这是你的选择。

UPDATE: 更新:

If you want one right way with everything, try Grails. 如果你想要一切正确的方法,试试Grails。 It's based on Spring and Hibernate. 它基于Spring和Hibernate。 A lot of the choices are made for you. 有许多选择供您选择。 It's like Ruby on Rails, except it uses Java, Groovy, Spring, and Hibernate. 它就像Ruby on Rails,除了它使用Java,Groovy,Spring和Hibernate。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM