- 浏览: 2552097 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Grails(11)Guide Book Chapter 11 Internationalization
11 Internationalization
grails also leverage the underlying Spring MVC internationalization support.
12 Security
12.4 Security Plugins
12.4.1 Spring Security
12.4.2 Shiro
13 Plugins
13.1 Creating and Installing Plugins
Creating Plugins
Creating a Grails plugin is a simple matter of running the command>
>grails create-plugin [PLUGIN NAME]
This is to create a plugin project
Installing and Distributing Plugins
To distribute a plugin you navigate to its root directory in a console and run
>grails package-plugin
This will create a zip file of the plugin starting with grails-then the plugin name and version.
Install the plugin from a local file
>grails install-plugin /path/to/grails-example-0.1.zip
Or we can install the plugin from remote server
>grails install-plugin http://server.com/plugins/grails-example-0.1.zip
13.2 Plugin Repositories
13.3 Understanding a Plugin's Structure
+ grails-app
+ controllers
+ domain
+ taglib
+ lib
+ src
+ java
+ groovy
+ web-app
+ js
+ css
13.4 Providing Basic
13.6 Hooking into Build Events
13.7 Hooking into Runtime Configuration
13.8 Adding Dynamic Methods at Runtime
13.9 Participating in Auto Reload Events
13.10 Understanding Plugin Load Order
14. Web Services
Web services are all about providing a web API onto your web application and are typically implemented in either REST or SOAP.
14.1 REST
REST is very simple and just involves using plain XML or JSON as a communication medium, combined with URL patterns that are 'representational' of the underlying system, and HTTP methods such as GET, PUT, POST and DELETE
URL patterns
static mappings = {
"/product/$id?"(resource: "product")
}
GET show
PUT update
POST save
DELETE delete
We can alter how HTTP methods are handled by using URL Mappings to map to HTTP methods:
"/product/$id"(controller: "product") {
action = [GET: "show", PUT: "update", DELETE: "delete", POST: "save"]
}
HTTP Methods
XML Marshalling - Reading
import grails.converters.XML
class ProductController {
def show(){
if(params.id && Product.exists(params.id)){
def p = Product.findByName(params.id)
render p as XML
}else{
def all = Product.list()
render all as XML
}
}
}
Data Binding
<?xml version="1.0" encoding="ISO-8859-1" ?>
<product>
<name>MacBook</name>
<vendor id="12">
<name>Apple</name>
</vendor>
</product>
def save(){
def p = new Product(params.product)
if(p.save()){
render p as XML
}else {
render p.errors
}
}
14.2 SOAP
CXF, Axis2, Metro
14.3 RSS and ATOM
15 Grails and Spring
15.1 The underpinning of Grails is Spring MVC
16. Grails and Hibernate
17. Scaffolding
Scaffolding lets you auto-generate a whole application for a given domain class.
Dynamic Scaffolding
The simplest way to get started with scaffolding is to enable it with the scaffold property. Set the scaffold property in the controller to true for the Book domain class.
class BookController {
static scaffold = true
}
class SomeController {
static scaffold = Author
}
Scaffold the controller to domain class Author.
With this configured, when I start my application the actions and views will be auto-generated at runtime. The following actions are dynamically implemented by default by the runtime scaffolding mechanism:
- list
- show
- edit
- delete
- create
- save
- update
A CRUD interface will also be generated. To access this open http://localhost:8080/appName/book
I can add new actions to a scaffolded controller.
class BookController {
static scaffold = Book
def changeAuthor(){ …snip… }
}
I can also override the scaffolded actions:
class BookController {
static scaffold = Book
//overrides scaffolded action
def list(){ …snip… }
}
Customizing the Generated Views
Static Scaffolding
>grails generate-controller Book
>grails generate-views Book
>grails generate-all Book //generate everything
>grails generate-all com.sillycat.Book
18 Deployment
>grails run-app
>grails run-war // Almost the same as run-app, but the applications are deployed as WAR files, so Hot-reloading is disabled.
WAR file
>grails war
References:
http://grails.org/doc/latest/guide/index.html
http://grails.org/doc/latest/guide/i18n.html
http://grails.org/doc/latest/guide/security.html
http://grails.org/doc/latest/guide/plugins.html
http://grails.org/doc/latest/guide/webServices.html
http://grails.org/doc/latest/guide/spring.html
http://grails.org/doc/latest/guide/hibernate.html
http://grails.org/doc/latest/guide/scaffolding.html
http://grails.org/doc/latest/guide/deployment.html
11 Internationalization
grails also leverage the underlying Spring MVC internationalization support.
12 Security
12.4 Security Plugins
12.4.1 Spring Security
12.4.2 Shiro
13 Plugins
13.1 Creating and Installing Plugins
Creating Plugins
Creating a Grails plugin is a simple matter of running the command>
>grails create-plugin [PLUGIN NAME]
This is to create a plugin project
Installing and Distributing Plugins
To distribute a plugin you navigate to its root directory in a console and run
>grails package-plugin
This will create a zip file of the plugin starting with grails-then the plugin name and version.
Install the plugin from a local file
>grails install-plugin /path/to/grails-example-0.1.zip
Or we can install the plugin from remote server
>grails install-plugin http://server.com/plugins/grails-example-0.1.zip
13.2 Plugin Repositories
13.3 Understanding a Plugin's Structure
+ grails-app
+ controllers
+ domain
+ taglib
+ lib
+ src
+ java
+ groovy
+ web-app
+ js
+ css
13.4 Providing Basic
13.6 Hooking into Build Events
13.7 Hooking into Runtime Configuration
13.8 Adding Dynamic Methods at Runtime
13.9 Participating in Auto Reload Events
13.10 Understanding Plugin Load Order
14. Web Services
Web services are all about providing a web API onto your web application and are typically implemented in either REST or SOAP.
14.1 REST
REST is very simple and just involves using plain XML or JSON as a communication medium, combined with URL patterns that are 'representational' of the underlying system, and HTTP methods such as GET, PUT, POST and DELETE
URL patterns
static mappings = {
"/product/$id?"(resource: "product")
}
GET show
PUT update
POST save
DELETE delete
We can alter how HTTP methods are handled by using URL Mappings to map to HTTP methods:
"/product/$id"(controller: "product") {
action = [GET: "show", PUT: "update", DELETE: "delete", POST: "save"]
}
HTTP Methods
XML Marshalling - Reading
import grails.converters.XML
class ProductController {
def show(){
if(params.id && Product.exists(params.id)){
def p = Product.findByName(params.id)
render p as XML
}else{
def all = Product.list()
render all as XML
}
}
}
Data Binding
<?xml version="1.0" encoding="ISO-8859-1" ?>
<product>
<name>MacBook</name>
<vendor id="12">
<name>Apple</name>
</vendor>
</product>
def save(){
def p = new Product(params.product)
if(p.save()){
render p as XML
}else {
render p.errors
}
}
14.2 SOAP
CXF, Axis2, Metro
14.3 RSS and ATOM
15 Grails and Spring
15.1 The underpinning of Grails is Spring MVC
16. Grails and Hibernate
17. Scaffolding
Scaffolding lets you auto-generate a whole application for a given domain class.
Dynamic Scaffolding
The simplest way to get started with scaffolding is to enable it with the scaffold property. Set the scaffold property in the controller to true for the Book domain class.
class BookController {
static scaffold = true
}
class SomeController {
static scaffold = Author
}
Scaffold the controller to domain class Author.
With this configured, when I start my application the actions and views will be auto-generated at runtime. The following actions are dynamically implemented by default by the runtime scaffolding mechanism:
- list
- show
- edit
- delete
- create
- save
- update
A CRUD interface will also be generated. To access this open http://localhost:8080/appName/book
I can add new actions to a scaffolded controller.
class BookController {
static scaffold = Book
def changeAuthor(){ …snip… }
}
I can also override the scaffolded actions:
class BookController {
static scaffold = Book
//overrides scaffolded action
def list(){ …snip… }
}
Customizing the Generated Views
Static Scaffolding
>grails generate-controller Book
>grails generate-views Book
>grails generate-all Book //generate everything
>grails generate-all com.sillycat.Book
18 Deployment
>grails run-app
>grails run-war // Almost the same as run-app, but the applications are deployed as WAR files, so Hot-reloading is disabled.
WAR file
>grails war
References:
http://grails.org/doc/latest/guide/index.html
http://grails.org/doc/latest/guide/i18n.html
http://grails.org/doc/latest/guide/security.html
http://grails.org/doc/latest/guide/plugins.html
http://grails.org/doc/latest/guide/webServices.html
http://grails.org/doc/latest/guide/spring.html
http://grails.org/doc/latest/guide/hibernate.html
http://grails.org/doc/latest/guide/scaffolding.html
http://grails.org/doc/latest/guide/deployment.html
发表评论
-
NodeJS12 and Zlib
2020-04-01 07:44 476NodeJS12 and Zlib It works as ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 337Traefik 2020(1)Introduction and ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 436Private Registry 2020(1)No auth ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 385Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 478NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 423Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 337Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 248GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 451GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 328GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 314Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 319Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 294Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 312Serverless with NodeJS and Tenc ... -
NodeJS MySQL Library and npmjs
2020-02-07 06:21 288NodeJS MySQL Library and npmjs ... -
Python Library 2019(1)requests and aiohttp
2019-12-18 01:12 261Python Library 2019(1)requests ... -
NodeJS Installation 2019
2019-10-20 02:57 573NodeJS Installation 2019 Insta ... -
Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts
2019-10-18 10:57 266Monitor Tool 2019(2)Monit on Mu ... -
Sqlite Database 2019(1)Sqlite3 Installation and Docker phpsqliteadmin
2019-09-05 11:24 368Sqlite Database 2019(1)Sqlite3 ... -
Supervisor 2019(2)Ubuntu and Multiple Services
2019-08-19 10:53 370Supervisor 2019(2)Ubuntu and Mu ...
相关推荐
《Grails 2 的终极指南》是一本深入探讨Grails框架精髓的专业书籍,该书以英文撰写,旨在为读者提供全面、深入的Grails框架学习资料。Grails框架基于Groovy语言,是一种高度动态、敏捷的Java应用开发框架,它简化了...
《The Definitive Guide to Grails 2》是Grails框架深入学习的重要参考资料,由业界专家撰写,旨在为开发者提供全面、详尽的Grails 2技术指导。这本书结合了理论与实践,不仅介绍了Grails的基本概念,还涵盖了高级...
**Grails 框架详解** Grails 是一个基于 Groovy 语言的开源Web应用程序框架,它构建在Java平台之上,旨在简化开发过程并提高生产力。Grails 的设计深受Ruby on Rails的影响,提供了MVC(模型-视图-控制器)架构模式...
《Grails 完全指南》:深入探索 Grails 框架的核心概念与实践 《Grails 完全指南》是 Grails 设计者 Graeme Rocher 和 Jeff Brown 联合编写的经典学习资料,旨在为开发者提供全面、深入的 Grails 框架理解和实践...
Definitive Guide to Grails
《The definitive Guide To Grails学习笔记》是一份深入探讨Grails框架的重要资源,它源于经典书籍《The Definitive Guide to Grails》的精华总结。Grails是一种基于Groovy语言的开源Web应用框架,旨在提高开发效率...
《Grails权威指南》是一本全面深入探讨Grails框架的专著,旨在帮助读者掌握这一强大的Web开发工具。Grails是一种基于Groovy语言的开源框架,它为构建现代、高效的应用程序提供了简洁高效的解决方案。本指南针对不同...
【Grails项目搭建详解】 Grails是一个基于Groovy语言的开源Web应用框架,它简化了开发过程,尤其适合快速构建动态网站。在Eclipse中搭建Grails项目可能相对复杂,但通过以下步骤,即使是初学者也能顺利进行。 1. *...
《The Definitive Guide to Grails 2》是关于Grails框架的一本权威指南,它为读者提供了深入理解和使用Grails 2开发Web应用程序所需的知识。Grails是一种基于Groovy语言的开源全栈式Web应用框架,它借鉴了Ruby on ...
《Grails用户手册》 Grails,作为一个基于Groovy语言的开源Web应用框架,深受开发者喜爱,它简化了Java开发的复杂性,提供了强大的MVC(Model-View-Controller)架构,以及丰富的插件系统。这份用户手册将帮助你...
《Grails技术精解与Web开发实践11-20章》是一本专注于Grails框架的深度解析书籍,尤其适合初学者和希望提升Grails开发技能的IT从业者。Grails是一种基于Groovy语言的开源Web应用框架,它以其高效、灵活和强大的特性...
对于Grails开发,我们需要的是Eclipse中的Grails插件,它能够提供对Grails项目的创建、运行、调试等一系列功能。 **Grails**是基于Groovy语言的全栈式Web开发框架,它借鉴了Ruby on Rails的设计理念,提供了快速...
The Definitive Guide to Grails 2nd Edition.pdf
Java web development is notoriously tedious, ... This book will get you up and running with Grails by putting it to use in constructing an original, working application from start to finish. Book Details