Groovy轻松入门——Grails实战基础篇

在学习任何东西之前,最重要的是培养兴趣,Groovy世界最耀眼的技术之一--Grails相信大家早已耳闻,我将通过Grails实战系列文章向您展现Grails的迷人风采,使您感受到Grails的魅力,以至疯狂地爱上Grails,并坠入Groovy的爱河。学Groovy,Grails与学Java一样,在实战之前需要搭建开发环境,您可以在 Groovy轻松入门--搭建Groovy开发环境 学习到如何搭建Groovy环境,之后我会讲一下如何搭建Grails环境,然后手把手地写个Demo程序告终,我还会抽空写篇“Groovy轻松入门--Grails实战之进阶篇”

一,搭建Grails环境
0,下载Grails( http://dist.codehaus.org/grails/grails-bin-1.0.zip)并解压到自己指定位置(我的位置是D:\D\MY_DEV\grails)
1,设置环境变量GRAILS_HOME(注意大写),过程与“设置环境变量GROOVY_HOME”相似
2,将%GRAILS_HOME%\bin添加到环境变量path中,过程与“将GROOVY_HOME目录下的bin追加到环境变量path中”相似
(如果只想进行Grails开发,可以不设GROOVY_HOME)

二,创建Grails Demo程序
3,打开“命令行”,选择当前目录(我的为D:\Temp\grails_apps),在黑底白字的窗口中输入“grails create-app demo”,不包括双引号“”,在您的屏幕中可以看到类似下面的输出结果:
D:\_DEV\grails_apps>grails create-app demo

Welcome to Grails 1.0 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: D:\D\MY_DEV\grails-1.0

Base Directory: D:\_DEV\grails_apps
Environment set to development
Note: No plugin scripts found
Running script D:\D\MY_DEV\grails-1.0\scripts\CreateApp.groovy
[mkdir] Created dir: D:\_DEV\grails_apps\demo\src
[mkdir] Created dir: D:\_DEV\grails_apps\demo\src\java
[mkdir] Created dir: D:\_DEV\grails_apps\demo\src\groovy
[mkdir] Created dir: D:\_DEV\grails_apps\demo\grails-app
[mkdir] Created dir: D:\_DEV\grails_apps\demo\grails-app\controllers
[mkdir] Created dir: D:\_DEV\grails_apps\demo\grails-app\services
[mkdir] Created dir: D:\_DEV\grails_apps\demo\grails-app\domain
[mkdir] Created dir: D:\_DEV\grails_apps\demo\grails-app\taglib
[mkdir] Created dir: D:\_DEV\grails_apps\demo\grails-app\utils
[mkdir] Created dir: D:\_DEV\grails_apps\demo\grails-app\views
[mkdir] Created dir: D:\_DEV\grails_apps\demo\grails-app\views\layouts
[mkdir] Created dir: D:\_DEV\grails_apps\demo\grails-app\i18n
[mkdir] Created dir: D:\_DEV\grails_apps\demo\grails-app\conf
[mkdir] Created dir: D:\_DEV\grails_apps\demo\test
[mkdir] Created dir: D:\_DEV\grails_apps\demo\test\unit
[mkdir] Created dir: D:\_DEV\grails_apps\demo\test\integration
[mkdir] Created dir: D:\_DEV\grails_apps\demo\scripts
[mkdir] Created dir: D:\_DEV\grails_apps\demo\web-app
[mkdir] Created dir: D:\_DEV\grails_apps\demo\web-app\js
[mkdir] Created dir: D:\_DEV\grails_apps\demo\web-app\css
[mkdir] Created dir: D:\_DEV\grails_apps\demo\web-app\images
[mkdir] Created dir: D:\_DEV\grails_apps\demo\web-app\WEB-INF\classes
[mkdir] Created dir: D:\_DEV\grails_apps\demo\web-app\META-INF
[mkdir] Created dir: D:\_DEV\grails_apps\demo\lib
[mkdir] Created dir: D:\_DEV\grails_apps\demo\grails-app\conf\spring
[mkdir] Created dir: D:\_DEV\grails_apps\demo\grails-app\conf\hibernate
[propertyfile] Creating new property file: D:\_DEV\grails_apps\demo\application.properties
[copy] Copying 2 files to D:\_DEV\grails_apps\demo
[copy] Copying 2 files to D:\_DEV\grails_apps\demo\web-app\WEB-INF
[copy] Copying 5 files to D:\_DEV\grails_apps\demo\web-app\WEB-INF\tld
[copy] Copying 87 files to D:\_DEV\grails_apps\demo\web-app
[copy] Copying 17 files to D:\_DEV\grails_apps\demo\grails-app
[copy] Copying 1 file to D:\_DEV\grails_apps\demo
[copy] Copying 1 file to D:\_DEV\grails_apps\demo
[copy] Copying 1 file to D:\_DEV\grails_apps\demo
[propertyfile] Updating property file: D:\_DEV\grails_apps\demo\application.properties
Created Grails Application at D:\_DEV\grails_apps/demo
D:\_DEV\grails_apps>


通过“grails create-app”这个命令,Grails自动帮我们创建了开发所需的工程环境。其实您现在就已经拥有了一个可运行的Web应用程序,
然后进入demo目录(“cd demo”),输入“grails run-app”,回车,启动这个‘五脏俱全’的程序雏形,打开浏览器,输入 http://localhost:8080/demo ,回车,看到了吧 :) 让我们继续吧,请停止这个程序(Ctrl + C)

4,在“命令行”中输入“cd demo”,回车,以进入demo目录,然后再输入“grails create-domain-class User”创建domain class即类似于pojo的pogo,它对应MVC中的Model,不过由Grails自动创建的pogo是空的,需要自己添加属性,约束(constraints)等。输出结果如下所示:

D:\_DEV\grails_apps\demo>grails create-domain-class User

Welcome to Grails 1.0 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: D:\D\MY_DEV\grails-1.0

Base Directory: D:\_DEV\grails_apps\demo
Environment set to development
Note: No plugin scripts found
Running script D:\D\MY_DEV\grails-1.0\scripts\CreateDomainClass.groovy
[copy] Copying 1 file to D:\_DEV\grails_apps\demo\grails-app\domain
Created for User
[copy] Copying 1 file to D:\_DEV\grails_apps\demo\test\integration
Created Tests for User
D:\_DEV\grails_apps\demo>



5,进入D:\Temp\grails_apps\demo\grails-app\domain(这个目录中存放着所有的domain class),打开User.groovy,修改为如下内容:
class User {
String name
String password

String toString() {
" $name : $password "
}

static constraints = {
name(blank: false )
password(blank: false , size: 6 .. 16 )
}
}


contraints这个类变量是定义一些约束的,比如name不能为空白,password不能为空白而且长度在6到16之间(包括6和16)

6,在“命令行”中输入“grails generate-all User”,为User产生所有CRUD操作需要的代码(如控制器UserController.groovy)和页面(如list.gsp),输出结果如下所示:
D:\_DEV\grails_apps\demo>grails generate-all User

Welcome to Grails 1.0 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: D:\D\MY_DEV\grails-1.0

Base Directory: D:\_DEV\grails_apps\demo
Environment set to development
Note: No plugin scripts found
Running script D:\D\MY_DEV\grails-1.0\scripts\GenerateAll.groovy
[mkdir] Created dir: D:\_DEV\grails_apps\demo\web-app\WEB-INF\lib
[mkdir] Created dir: C:\Documents and Settings\Daniel\.grails\1.0\projects\demo\classes
[groovyc] Compiling 7 source files to C:\Documents and Settings\Daniel\.grails\1.0\projects\demo\classes
[mkdir] Created dir: C:\Documents and Settings\Daniel\.grails\1.0\projects\demo\resources\grails-app\i18n
[native2ascii] Converting 10 files from D:\_DEV\grails_apps\demo\grails-app\i18n to C:\Documents and Settings\Daniel\.grails\1.0\projects\demo\re
sources\grails-app\i18n
[copy] Copying 1 file to C:\Documents and Settings\Daniel\.grails\1.0\projects\demo\classes
[copy] Copying 1 file to C:\Documents and Settings\Daniel\.grails\1.0\projects\demo\resources
[copy] Copying 1 file to C:\Documents and Settings\Daniel\.grails\1.0\projects\demo
[0] spring.GrailsWebApplicationContext Refreshing org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@2b2057: display name [org
.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@2b2057]; startup date [Tue Feb 05 23:26:45 CST 2008]; root of context hierarch
y
[16] spring.GrailsWebApplicationContext Bean factory for application context [org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationConte
xt@2b2057]: org.springframework.beans.factory.support.DefaultListableBeanFactory@eebf17
Generating views for domain class User ...
Generating controller for domain class User ...
Finished generation for domain class User
D:\_DEV\grails_apps\demo>


7,修改demo\grails-app\controllers\UserController.groovy的内容为: class UserController {

def loginService // 新增的代码

def index = { redirect(action:list,params:params) }

// the delete, save and update actions only accept POST requests
def allowedMethods = [delete:'POST', save:'POST', update:'POST']

def list = {
if(!params.max) params.max = 10
[ userList: User.list( params ) ]
}

def show = {
def user = User.get( params.id )

if(!user) {
flash.message = "User not found with id ${params.id}"
redirect(action:list)
}
else { return [ user : user ] }
}

def delete = {
def user = User.get( params.id )
if(user) {
user.delete()
flash.message = "User ${params.id} deleted"
redirect(action:list)
}
else {
flash.message = "User not found with id ${params.id}"
redirect(action:list)
}
}

def edit = {
def user = User.get( params.id )

if(!user) {
flash.message = "User not found with id ${params.id}"
redirect(action:list)
}
else {
return [ user : user ]
}
}

def update = {
def user = User.get( params.id )
if(user) {
user.properties = params
if(!user.hasErrors() && user.save()) {
flash.message = "User ${params.id} updated"
redirect(action:show,id:user.id)
}
else {
render(view:'edit',model:[user:user])
}
}
else {
flash.message = "User not found with id ${params.id}"
redirect(action:edit,id:params.id)
}
}

def create = {
def user = new User()
user.properties = params
return ['user':user]
}

def save = {
def user = new User(params)
if(!user.hasErrors() && user.save()) {
flash.message = "User ${user.id} created"
redirect(action:show,id:user.id)
}
else {
render(view:'create',model:[user:user])
}
}

// 新增的代码
def login = {
if (request.method == 'POST') {
User u = new User()
u.properties = params

if (!u.validate()) {
render(view:'login', model:[user:u])
}

if (params.name && params.password) {

def user = loginService.check(u)

if (user) {
flash.message = "Welcome ${user.name}"
render(view: "ok", model: [user: user])
} else {
flash.error = "Invalid ${u.name} with ${u.password}"
render(view: "login", model: [user: u])
}
} else {
render(view: "login", model: [user: u])
}
}
}
}

大家或许也看到了LoginService这个类,我将在后面演示创建它,这个LoginService类封装了所有登陆相关的业务逻辑,Grails会自动将其注入到UserController中

8,在“命令行”中,输入“grails create-service Login”,创建LoginService.groovy,输出:
D:\_DEV\grails_apps\demo>grails create-service Login

Welcome to Grails 1.0 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: D:\D\MY_DEV\grails-1.0

Base Directory: D:\_DEV\grails_apps\demo
Environment set to development
Note: No plugin scripts found
Running script D:\D\MY_DEV\grails-1.0\scripts\CreateService.groovy
[copy] Copying 1 file to D:\_DEV\grails_apps\demo\grails-app\services
Created Service for Login
[copy] Copying 1 file to D:\_DEV\grails_apps\demo\test\integration
Created ServiceTests for Login
D:\_DEV\grails_apps\demo>



9,修改demo\grails-app\services\LoginService.groovy的内容为:

class LoginService {

boolean transactional = true

def check(User u) {
def user = User.findWhere(name: u.name, password: u.password)
return user
}

}



10,在demo\grails-app\views\user目录下创建login.gsp和ok.gsp,它们对应MVC中的View,内容分别为:
login.gsp (复制demo\grails-app\views\user\create.gsp的内容到login.gsp中,并修改):

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="main" />
<!-- 将Create User修改为Login -->
<title>Login</title>
</head>
<body>
<div class="nav">
<span class="menuButton"><a class="home" href="${createLinkTo(dir:'')}">Home</a></span>
<span class="menuButton"><g:link class="list" action="list">User List</g:link></span>
</div>
<div class="body">
<!-- 将Create User修改为Login -->
<h1>Login</h1>
<!-- 将flash.message修改为flash.error -->
<g:if test="${flash.error}">
<!-- 将class="message"修改为class="errors", 将flash.message修改为flash.error -->
<div class="errors">${flash.error}</div>
</g:if>
<g:hasErrors bean="${user}">
<div class="errors">
<g:renderErrors bean="${user}" as="list" />
</div>
</g:hasErrors>

<!-- 将action="save"修改为action="login" -->
<g:form action="login" method="post" >
<div class="dialog">
<table>
<tbody>

<tr class="prop">
<td valign="top" class="name">
<label for="name">Name:</label>
</td>
<td valign="top" class="value ${hasErrors(bean:user,field:'name','errors')}">
<input type="text" id="name" name="name" value="${fieldValue(bean:user,field:'name')}"/>
</td>
</tr>

<tr class="prop">
<td valign="top" class="name">
<label for="password">Password:</label>
</td>
<td valign="top" class="value ${hasErrors(bean:user,field:'password','errors')}">
<input type="text" maxlength="16" id="password" name="password" value="${fieldValue(bean:user,field:'password')}"/>
</td>
</tr>

</tbody>
</table>
</div>
<div class="buttons">
<!-- 将value="Create"修改为value="Login" -->
<span class="button"><input class="save" type="submit" value="Login" /></span>
</div>
</g:form>
</div>
</body>
</html>



ok.gsp:

<g:if test="${flash.message}">
<div class="message">${flash.message}</div>
</g:if>

Name: ${user?.name} <br>
Password: ${user?.password}



11,修改demo\grails-app\conf\BootStrap.groovy,初始化数据库:将一个User实例保存到数据库(grails自带hsqldb和jetty)中,内容如下:
class BootStrap {

def init = { servletContext ->
new User(name: "demo", password: "123456").save()
}

def destroy = {
}
}


12,在“命令行”中,输入“grails run-app”,运行我们的Web应用,输出如下:

D:\_DEV\grails_apps\demo>grails run-app

Welcome to Grails 1.0 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: D:\D\MY_DEV\grails-1.0

Base Directory: D:\_DEV\grails_apps\demo
Environment set to development
Note: No plugin scripts found
Running script D:\D\MY_DEV\grails-1.0\scripts\RunApp.groovy
[groovyc] Compiling 4 source files to C:\Documents and Settings\Daniel\.grails\1.0\projects\demo\classes
Running Grails application..
2008-02-05 23:46:08.912::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
2008-02-05 23:46:08.066::INFO: jetty-6.1.4
2008-02-05 23:46:08.347::INFO: No Transaction manager found - if your webapp requires one, please configure one.
2008-02-05 23:46:09.081:/demo:INFO: Set web app root system property: 'demo' = [D:\_DEV\grails_apps\demo\web-app\]
2008-02-05 23:46:09.081:/demo:INFO: Initializing Log4J from [file:C:\Documents and Settings\Daniel/.grails/1.0/projects/demo/resources/log4j.pro
perties]
2008-02-05 23:46:09.113:/demo:INFO: Initializing Spring root WebApplicationContext
[0] spring.GrailsWebApplicationContext Refreshing org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@5facbd: display name [org
.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@5facbd]; startup date [Tue Feb 05 23:46:14 CST 2008]; parent: org.springframew
ork.web.context.support.XmlWebApplicationContext@1fef80a
[0] spring.GrailsWebApplicationContext Bean factory for application context [org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContex
t@5facbd]: org.springframework.beans.factory.support.DefaultListableBeanFactory@aa4c7c
2008-02-05 23:46:21.590:/demo:INFO: Initializing Spring FrameworkServlet 'grails'
2008-02-05 23:46:21.871::INFO: Started SelectChannelConnector@0.0.0.0:8080
Server running. Browse to http://localhost:8080/demo




13,打开浏览器,输入:http://localhost:8080/demo/user/login ,在Name处输入demo,Password处输入123456,点击‘Login’,跳转到成功页面:

Welcome demo
Name: demo
Password: 123456



如果您对Grails的工程目录不太熟悉,我这里为大家提供了一张表,详细地描述了各目录的用途:

《Grails权威指南》表3-1.Grails工程目录

目录名称 相关描述
grails-app 此目录包含了Grails应用程序的核心工件(core artifact)
+ conf 此目录包含了诸如DevelopmentDataSource.groovy的配置文件
+ controllers 此目录包含了处理请求(request)的控制器(controller),Grails控制器将在第7章中进行讲解
+ domain 此目录包含了领域模型(domain model),领域模型将在第4章进行讲解
+ i18n 此目录包含了用于国际化的消息束(message bundle)(译者注:指的是properties文件,如messages.properties)
+ services 此目录包含了封装业务逻辑的service文件,service将在第10章中进行讲解
+ taglib 此目录包含了辅助页面生成的动态标签库,动态标签将在第8章中进行讲解
+ views 此目录包含了Groovy服务器页面(GSP)以及JSP页面
+ layouts 此目录包含了GSP或JSP的布局(layout),这些布局由SiteMesh提供支持,这将在第8章中进行讲解
grails-test 此目录包含了应用程序的单元测试
hibernate 此目录包含了可选的Hibernate配置文件,这将在第11章中进行讲解
lib 此目录包含了jar文件
spring 此目录包含了可选的Spring配置文件,这将在第11章中进行讲解
src 此目录包含了其他Groovy和Java资源
+ java 此目录包含了待编译的Java源文件
+ groovy 此目录包含了待编译的Groovy源文件
web-app 此目录包含了Web应用程序的资源(CSS,JavaScript等)


注:Grails1.0已将hibernate和spring两个目录移到grails-app\conf目录下了,
而grails-test目录也更名为test,test目录下有integration目录和unit目录,分别存放集成测试代码和单元测试代码

想象一下用您平时做项目时所用的框架组合(比如SSH)来创建同样的Web应用程序,您立刻会感受,Grails让我们专注于业务逻辑,而不用浪费时间在那些scaffolding code(如配置文件)上。从今天开始,您不用再羡慕那些Ruby程序员所用的RoR了,您大可以使用Grails来高效开发Web应用。

您也可以访问Grails官方网站(http://www.grails.org)进一步学习。
groovy grails简介 对grails groovy的实践的小例子。简单易懂。 立即下载

相关推荐

Groovy和Grails配置方法

Groovy和Grails配置方法 教你从0入手,一步一步深入安装和测试,包含环境和语言的下载地址

Groovy和Grails简介

摘要  Java Web应用程序框架是企业Java得以成功的重要原因之一。人们怀疑如果没有Apache Struts框架Java EE是否能够如此成功。虽然底层编程语言很重要,但通常是框架使编程语言成为引人注目的中心的。如果您经常访问讨论论坛,就会注意到Ruby语言和Ruby On Rails框架之间也是这种情况。Ruby已经出现十多年了,然而只是在Ruby On Rails框架流行之后,开发

疯猫 3338

用Matlab搞定Delta并联机器人运动学:从建模到正逆解完整流程(附代码)

本文详细介绍了如何使用Matlab实现Delta并联机器人的运动学分析,包括几何建模、正逆解求解及可视化验证。通过符号计算和数值迭代法,解决非线性方程组问题,并提供完整代码示例,帮助读者快速掌握Delta机器人的运动学计算与应用。

weixin_30955617的博客 185

Groovy&Grails理解–第2部分

ils子 Grails是基于Groovy和Java的Web框架,可以将其部署到现有的Java Web服务器中,例如Tomcat或Jetty。 它的脚手架功能使您可以在几分钟内创建一个新项目。 Grails基于“基于配置的约定”的思想,该思想允许应用程序根据命名方案(而不是使用配置文件,例如XML文件)自动连接自身。 Grails框架无需任何配置即可进行实例开发。 Grails通过在开发过...

402

ANSYS Sherlock新手避坑:从ODB++文件导入到属性匹配的完整流程(附官方教程路径)

本文详细解析了ANSYS Sherlock从ODB++文件导入到属性匹配的完整流程,帮助新手避开常见陷阱。内容包括环境准备、官方教程使用技巧、ODB++导入关键检查点、属性验证策略及常见报错解决方案,特别强调了路径设置和材料匹配的重要性,提升仿真效率。

weixin_42519781的博客 460

工程师必看:如何用MINITAB快速计算传感器寿命(附详细步骤)

本文为工程师提供了使用MINITAB软件快速计算传感器寿命的详细实战指南。文章重点阐述了如何通过数据预处理、回归分析拟合阿伦尼斯模型,并最终预测平均寿命与置信区间,帮助工程师高效处理加速寿命试验数据,提升可靠性分析工作的准确性与效率。

weixin_29296241的博客 253

groovy2.4.12+grails3.3.0+gradle4.8.1环境搭建

groovy2.4.12+grails3.3.0+gradle4.8.1环境搭建和helloworld

小周今天Code了吗 466

UDS 诊断 - CommunicationControl(通信控制)(0x28)服务 诊断

字节参数名称字节值#1CommunicationControl(通信控制)请求SID0x28#2#3communicationType(通信类型)#4nodeIdentificationNumer(节点标识符)(高位字节)controlType 为 0x04 或 0x05 时,使用该参数#5nodeIdentificationNumer(节点标识符)(低位字节)controlType 为 0x04 或 0x05 时,使用该参数。

耳朵东金子千的博客 1830

《Groovy极简教程》第6章 Groovy与Grails

《Groovy极简教程》第6章 Groovy与Grails

weixin_34409703的博客 98

DSSAT模型实战:从基础配置到气候情景模拟

本文详细介绍了DSSAT模型在农业模拟中的应用,从基础配置到气候情景模拟的全流程实战指南。通过土壤-植物-大气连续体的动态关系建模,DSSAT能精准预测作物产量,误差率低至8%。文章涵盖气象数据处理、土壤参数配置、管理措施调控等核心技巧,并提供了Python脚本和可视化方法,助力农业科研与决策。

weixin_29264201的博客 1030

模仿学习(Imitation Learning)概述

什么是模仿学习呢?简单来说,模仿学习(Imitation Learning),就是要训练机器能够复制人类的连续动作,进而达到模仿的目的。其实,Imitation Learning的实用性很高,假设今天有一个训练场景,你不知道该怎么定奖励值(reward),但是你可以收集到专家的示范数据(expert demonstration data),你就可以考虑用Imitation Learning这个方法。因此,模仿学习也被寄予很高的期待,成为下一代强人工智能的关键技术。......

qq_22749225的博客 2万+

Groovy轻松入门——Grails实战之GORM篇

  Groovy轻松入门——Grails实战之GORM篇(更新于2007年4月8日) GORM就是以前我刚学Groovy没多久时想实现的功能,它使开发人员不需要关心数据库方面,也不需要任何配置,只需专心用OO思想设计自己的系统,还有一个好处就是开发时不用备份数据库,因为GORM会自动帮你建表以及约束(但数据库需要你自己建),让我们来看一下用Grails开发是多么简单高效吧! 在Grails...

新页小苗 305

Unity 热更新技术 | (二) AssetBundle - 完整系列教程学习

开始学习热更新方面系列知识,就从这一篇开始吧! 本系列教程 会从热更新基本概念出发,详细介绍热更新相关的全套知识点。 如热更新技术基本原理、热更新主流方案、AssetBundle系列教程、Lua语言编程、Lua与Unity交互教程、Xlua框架使用、热更新实战教程等方面。 热更新作为一个开发者必备技能,如果想学习的话,可以从现在开始了哦~ 接下来从 AssetBundle - 完整系列教程学习 开始学习吧!

努力前行,总会成为自己心中的那道光 1万+

grails 转为java_【转】Groovy轻松入门——Grails实战基础篇

在学习任何东西之前,最重要的是培养兴趣,Groovy世界最耀眼的技术之一--Grails相信大家早已耳闻,我将通过Grails实战系列文章向您展现Grails的迷人风采,使您感受到Grails的魅力,以至疯狂地爱上Grails,并坠入Groovy的爱河。学Groovy,Grails与学Java一样,在实战之前需要搭建开发环境,您可以在Groovy轻松入门--搭建Groovy开发环境学习到如何搭建...

weixin_27061475的博客 304

高压控制单元与接触器 —— BMS电池的“高压大门”

高压接触器在BMS电池管理系统中扮演着“高压大门”的角色,负责控制电池包与整车高压母线的连接与隔离。接触器的工作原理基于线圈产生的磁力吸合接点,通过主触点接通高压电流路径,辅助触点检测状态,灭弧结构保护接点。预充电路的设计是为了避免直接连接大电容时产生的浪涌电流冲击,通过预充电阻逐步充电,确保系统安全上电。接触器控制策略包括顺序控制、辅助触点检测、温度监控、故障断电和背靠背MOS辅助控制,以确保系统的高效和安全运行。工程师在选择接触器型号、控制线圈、检测状态、软件冗余控制和预充失败保护等方面提供了具体建议。

weixin_43199439的博客 828

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

Groovy轻松入门——Grails实战之Ajax篇

Ajax虽是“旧酒装新瓶”,但其威力着实不小。近两年来可谓红透半边天,它之所以能为大众接受,其中一个很大的原因就是提高了用户浏览体验,能更逼真的模拟出GUI界面。好了,Ajax的益处就说到这里,下面让我们看下Grails是如何帮助我们方便地应用Ajax的:如果您对下面说设计的内容有点不解,那么您可以先看一下 Groovy轻松入门——Grails实战基础篇,然后开始我们的Ajax之旅。 1, 在命令

wudith的专栏 916

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Groovy轻松入门——Grails实战基础篇(1)

在学习任何东西之前,最重要的是培养兴趣,Groovy世界最耀眼的技术之一--Grails相信大家早已耳闻,我将通过Grails实战系列文章向您展现Grails的迷人风采,使您感受到Grails的魅力,以至疯狂地爱上Grails,并坠入Groovy的爱河。学Groovy,Grails与学Java一样,在实战之前需要搭建开发环境,您可以在 Groovy轻松入门--搭建Groovy开发环境 学习到如何搭

Kc 653

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

【转载】Groovy轻松入门——Grails实战基础篇

Groovy轻松入门——Grails实战基础篇(更新于2008.02.05) 在学习任何东西之前,最重要的是培养兴趣,Groovy世界最耀眼的技术之一--Grails相信大家早已耳闻,我将通过Grails实战系列文章向您展现Grails的迷人风采,使您感受到Grails的魅力,以至疯狂地爱上Grails,并坠入Groovy的爱河。学Groovy,Grails与学Java一样,在实战之前需要搭建开发...

mht13895099346的专栏 226

Groovy轻松入门——Grails实战之Web Flow篇

摘要:Spring Web Flow是Spring家族中的一位成员,他能简化Web应用的开发。在Grails0.6中就集成了Spring Web Flow这一Web应用开发利器。下面通过一个实例向大家展示一下在Grails中如何方便的使用Spring Web Flow。 Spring Web Flow是Spring家族中的一位成员,他能简化Web应用的开发。在Grails0.6中就集成了Spr

Kc 2835

【转载】Groovy轻松入门——Grails实战之GORM篇

Groovy轻松入门——Grails实战之GORM篇(更新于2007年4月8日) GORM就是以前我刚学Groovy没多久时想实现的功能,它使开发人员不需要关心数据库方面,也不需要任何配置,只需专心用OO思想设计自己的系统,还有一个好处就是开发时不用备份数据库,因为GORM会自动帮你建表以及约束(但数据库需要你自己建),让我们来看一下用Grails开发是多么简单高效吧! 在Grails0.6+中,...

mht13895099346的专栏 211

Groovy轻松入门——Grails实战基础篇(3)

4,在“命令行”中,输入“grails create-controller Login”,创建登陆(login)的控制器LoginController,它对应MVC中的Controller,让它负责登陆相关业务,输出如下:D:/Temp/grails_apps/demo>grails create-controller LoginWelcome to Grails 0.

Kc 943

Groovy轻松入门——Grails实战基础篇(4)

 ok.gsp:9,修改demo/grails-app/conf/ApplicationBootStrap.groovy,将一个User实例保存到数据库(grails自带hsqldb和jetty)中,内容如下:class ApplicationBootStrap { def init = { servletContext -> new

Kc 771
上一篇: Groovy轻松入门——搭建Groovy开发环境
下一篇: 查询相同记录
lamdu
博客等级 码龄18年 0粉丝 37原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值