Grails与其他Java Web框架相比有哪些优势? [英] What are the Grails advantages over other Java Web Frameworks?

查看:81
本文介绍了Grails与其他Java Web框架相比有哪些优势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾与JSF,Spring MVC和Struts合作过,我认为我在这些框架上获得了很好的水平。最近我听说有许多优秀的开发人员正在学习Grails,并将其用于他们的项目中。



Grails与其他框架相比有什么实际优势?除了我了解其他框架之外,还有值得去学习吗?什么是Grails周围的嗡嗡声,仅仅是因为Groovy?



注意:我在SO中进行了研究,我发现的唯一相关问题是并没有提到Grails

正如你所说,Grails是建立在Groovy基础之上的,它提供了更高效的直接好处。 Groovy语法比Java更加简洁,在一行Groovy代码中执行某些操作要容易得多,这些代码需要Java中的几个。



Grails专门为您提供了一个与其他Web框架相比,它有很多优点(但我只能谈论Struts 1.x,2.x和SpringMVC) - Grails实际上是建立在SpringMVC之上的,并且可以使用Spring集成其他组件。




  • 数据库迁移和版本控制 - 没有更多的应用程序与数据库模式综合症不同步。大多数Java Web应用程序都会受此影响。


  • Artefacts - 使创建新控制器和组件变得更容易。不再需要创建一个控制器,配置它并将其放入您的Web应用程序的正确位置。卫生署!脚手架还为您提供了所有的初始组件,以允许您开始构建页面并自定义。

  • 简单验证(比Struts 1.x更简单) username(大小:6..10,空白:false)指定用户名字段的两个验证规则为特定长度且非空白。这在其他Java Web应用程序框架中有点难。 建立在Webflow中(通过Spring webflow),这使得创建复杂的工作流变得更加简单。 Struts 2可以支持Webflow,但通过一个插件,如果我记得有点奇怪。 Spring也可以。

  • 拦截器 - SpringMVC也有这些。 Flash范围请参阅 http://grails.org/doc/docs/1.1/ref/Controllers/flash.html


  • 更好的数据绑定 - Struts 2相当不错,比Struts 1好得多.SpringMVC也不错。



还有一些,请查看文档以获取更多详细信息: http://grails.org/doc/1.1.1/

I've worked with JSF, Spring MVC and Struts and I think I got a good level on these frameworks. Recently I heard that many good developers I worked with are learning Grails and using it in their projects.

What are the practical advantages of Grails over other frameworks? Is worth to learn it besides I know other frameworks? What is all the buzz around Grails, is it only because of Groovy?

NOTE: I did research in SO and the only related question I found was this and Grails is not mentioned

解决方案

Grails is, like you say, built off Groovy which gives the immediate benefit of being more productive. The Groovy syntax is much terser than Java, it's much easier to do things in one line of Groovy code that would take you several in Java.

Grails specifically provides you with a number of advantages over other web frameworks (I can only talk for Struts 1.x, 2.x and SpringMVC however) - Grails is actually built on top of SpringMVC by the way and you can integrate other components using Spring.

  • Database Migrations and Versioning - no more application out of sync with database schema syndrome. Most Java web apps suffer from this.

  • Artefacts - which make creating new controllers and components easier. No more create a controller, configure it and stuff it into the right place in your web app. doh! Scaffolding also provides you with all some initial components to allow you to start building your pages and customising

  • Simpler validation (def simpler than Struts 1.x), e.g. username(size:6..10, blank:false) specifies two validation rules for a username field to be of a specific length and non blank. It's a bit harder in the other Java web app frameworks.

  • Built in Webflow (via Spring webflow) which makes creating complex workflows much simpler. Struts 2 can support Webflow, but via a plugin which is a little odd if I rememeber. Spring can too.

  • Interceptors - SpringMVC also has these.

  • Flash scope, see http://grails.org/doc/docs/1.1/ref/Controllers/flash.html

  • Better data binding - Struts 2 is pretty good, much better than Struts 1. SpringMVC is also good.

There's a few more, check out the documentation for more details: http://grails.org/doc/1.1.1/

这篇关于Grails与其他Java Web框架相比有哪些优势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆