- 浏览: 175416 次
- 性别:
- 来自: 郴州
-
文章分类
最新评论
-
craengjava:
很好的,如果可以,希望分享一下详细过程,谢谢
grails and tinymce -
Iwishyou:
汗 这错别字多的...终于面试了下载抵制
Grails中文文档beta发布 -
lauphai:
什么时候有中文文档呀
grails1.2中文文档即将发布 -
Javabengou:
现在从办公室调到建行新开的营业厅所以比较忙没时间做,如果谁想接 ...
grails1.2中文文档即将发布 -
by5739:
现在出了吗?
grails1.2中文文档即将发布
h4. Returning the Model
h4. 返回模型(Model)
A model is essentially a map that the view uses when rendering. The keys within that map translate to variable names accessible by the view. There are a couple of ways to return a model, the first way is to explicitly return a map instance:
模型(Model)本质上是个map类型,当视图(view)被渲染时使用。map中的keys转变成变量名让view(视图)访问。这里有一对方式来返回模型(Model),第一种方式是明确返回map实体:
{code:java}
def show = {
[ book : Book.get( params.id ) ]
}
{code}
If no explicit model is returned the controller's properties will be used as the model thus allowing you to write code like this:
假如没有明确的模型(Model)被返回,控制器的属性将被当做模型(Model)来使用,因此允许你的代码写成下面这样:
{code:java}
class BookController {
List books
List authors
def list = {
books = Book.list()
authors = Author.list()
}
}
{code}
{note}
This is possible due to the fact that controllers are prototype scoped. In other words a new controller is created for each request. Otherwise code such as the above would not be thread safe.
这可能是由于事实上控制器(Controllers)是prototype(原型)范围。换句话说,每次请求,一个新的控制器(Controllers)会被创建。否则上面的代码将不是线程安全的。
{note}
In the above example the @books@ and @authors@ properties will be available in the view.
在上面示例中的 @books@ 和 @authors@属性将在view(视图)中被使用。
A more advanced approach is to return an instance of the Spring [ModelAndView|api:org.springframework.web.servlet.ModelAndView] class:
一个更加高级的方法是返回Spring [ModelAndView|api:org.springframework.web.servlet.ModelAndView] 类。
{code:java}
import org.springframework.web.servlet.ModelAndView
...
def index = {
def favoriteBooks = ... // get some books just for the index page, perhaps your favorites
// forward to the list view to show them
return new ModelAndView("/book/list", [ bookList : favoriteBooks ])
}
{code}
h4. Selecting the View
h4.选择视图( View)
In both the previous two example there was no code that specified which [view:guide:GSP] to render. So how does Grails know which view to pick? The answer lies in the conventions. For the action:
在先前的两个示例里没有代码指定哪个 [view:guide:GSP]去渲染。那么Grails怎么知道哪个视图( View)被选取了?答案在于规约。观察这个Actions(操作):
{code:java}
class BookController {
def show = {
[ book : Book.get( params.id ) ]
}
}
{code}
Grails will automatically look for a view at the location @grails-app/views/book/show.gsp@ (actually Grails will try to look for a JSP first, as Grails can equally be used with JSP).
Grails 将自动在 @grails-app/views/book/show.gsp@ 位置寻找一个视图( View)(事实上 Grails将首先尝试寻找JSP页面, 因为Grails 可以等同的用于JSP).
If you wish to render another view, then the [render|controllers] method there to help:
假如你希望渲染另一个视图( View),那么[render|controllers]方法可以帮助你:
{code:java}
def show = {
def map = [ book : Book.get( params.id ) ]
render(view:"display", model:map)
}
{code}
In this case Grails will attempt to render a view at the location @grails-app/views/book/display.gsp@. Notice that Grails automatically qualifies the view location with the @book@ folder of the @grails-app/views@ directory. This is convenient, but if you have some shared views you need to access instead use:
在这种情况下Grails将尝试渲染 @grails-app/views/book/display.gsp@位置上的视图( View)。注意,Grails自动描述位于@book@文件夹中的 @grails-app/views@ 路径位置的视图( View)。很便利,但是假如你拥有一些共享的视图( View)用来存取,作为替代使用:
{code:java}
def show = {
def map = [ book : Book.get( params.id ) ]
render(view:"/shared/display", model:map)
}
{code}
In this case Grails will attempt to render a view at the location @grails-app/views/shared/display.gsp@.
在这种情况下Grails将尝试渲染@grails-app/views/shared/display.gsp@位置上的视图( View)。
Rendering a Response
渲染Response(响应)
Sometimes its easier (typically with Ajax applications) to render snippets of text or code to the response directly from the controller. For this the highly flexible "render" method can be used:
有时它很容易的渲染来自创建控制器(Controllers)小块文本或者代码的响应(通常使用Ajax应用程序)。因为使用了高度灵活的 "render"方法。
{code:java}
render "Hello World!"
{code}
The above code writes the text "Hello World!" to the response, other examples include:
上面的代码打印出"Hello World!" 响应,其他的示例包括:
{code:java}
// write some markup
render {
for(b in books) {
div(id:b.id, b.title)
}
}
// render a specific view
render(view:'show')
// render a template for each item in a collection
render(template:'book_template', collection:Book.list())
// render some text with encoding and content type
render(text:"<xml>some xml</xml>",contentType:"text/xml",encoding:"UTF-8")
{code}
h4. 返回模型(Model)
A model is essentially a map that the view uses when rendering. The keys within that map translate to variable names accessible by the view. There are a couple of ways to return a model, the first way is to explicitly return a map instance:
模型(Model)本质上是个map类型,当视图(view)被渲染时使用。map中的keys转变成变量名让view(视图)访问。这里有一对方式来返回模型(Model),第一种方式是明确返回map实体:
{code:java}
def show = {
[ book : Book.get( params.id ) ]
}
{code}
If no explicit model is returned the controller's properties will be used as the model thus allowing you to write code like this:
假如没有明确的模型(Model)被返回,控制器的属性将被当做模型(Model)来使用,因此允许你的代码写成下面这样:
{code:java}
class BookController {
List books
List authors
def list = {
books = Book.list()
authors = Author.list()
}
}
{code}
{note}
This is possible due to the fact that controllers are prototype scoped. In other words a new controller is created for each request. Otherwise code such as the above would not be thread safe.
这可能是由于事实上控制器(Controllers)是prototype(原型)范围。换句话说,每次请求,一个新的控制器(Controllers)会被创建。否则上面的代码将不是线程安全的。
{note}
In the above example the @books@ and @authors@ properties will be available in the view.
在上面示例中的 @books@ 和 @authors@属性将在view(视图)中被使用。
A more advanced approach is to return an instance of the Spring [ModelAndView|api:org.springframework.web.servlet.ModelAndView] class:
一个更加高级的方法是返回Spring [ModelAndView|api:org.springframework.web.servlet.ModelAndView] 类。
{code:java}
import org.springframework.web.servlet.ModelAndView
...
def index = {
def favoriteBooks = ... // get some books just for the index page, perhaps your favorites
// forward to the list view to show them
return new ModelAndView("/book/list", [ bookList : favoriteBooks ])
}
{code}
h4. Selecting the View
h4.选择视图( View)
In both the previous two example there was no code that specified which [view:guide:GSP] to render. So how does Grails know which view to pick? The answer lies in the conventions. For the action:
在先前的两个示例里没有代码指定哪个 [view:guide:GSP]去渲染。那么Grails怎么知道哪个视图( View)被选取了?答案在于规约。观察这个Actions(操作):
{code:java}
class BookController {
def show = {
[ book : Book.get( params.id ) ]
}
}
{code}
Grails will automatically look for a view at the location @grails-app/views/book/show.gsp@ (actually Grails will try to look for a JSP first, as Grails can equally be used with JSP).
Grails 将自动在 @grails-app/views/book/show.gsp@ 位置寻找一个视图( View)(事实上 Grails将首先尝试寻找JSP页面, 因为Grails 可以等同的用于JSP).
If you wish to render another view, then the [render|controllers] method there to help:
假如你希望渲染另一个视图( View),那么[render|controllers]方法可以帮助你:
{code:java}
def show = {
def map = [ book : Book.get( params.id ) ]
render(view:"display", model:map)
}
{code}
In this case Grails will attempt to render a view at the location @grails-app/views/book/display.gsp@. Notice that Grails automatically qualifies the view location with the @book@ folder of the @grails-app/views@ directory. This is convenient, but if you have some shared views you need to access instead use:
在这种情况下Grails将尝试渲染 @grails-app/views/book/display.gsp@位置上的视图( View)。注意,Grails自动描述位于@book@文件夹中的 @grails-app/views@ 路径位置的视图( View)。很便利,但是假如你拥有一些共享的视图( View)用来存取,作为替代使用:
{code:java}
def show = {
def map = [ book : Book.get( params.id ) ]
render(view:"/shared/display", model:map)
}
{code}
In this case Grails will attempt to render a view at the location @grails-app/views/shared/display.gsp@.
在这种情况下Grails将尝试渲染@grails-app/views/shared/display.gsp@位置上的视图( View)。
Rendering a Response
渲染Response(响应)
Sometimes its easier (typically with Ajax applications) to render snippets of text or code to the response directly from the controller. For this the highly flexible "render" method can be used:
有时它很容易的渲染来自创建控制器(Controllers)小块文本或者代码的响应(通常使用Ajax应用程序)。因为使用了高度灵活的 "render"方法。
{code:java}
render "Hello World!"
{code}
The above code writes the text "Hello World!" to the response, other examples include:
上面的代码打印出"Hello World!" 响应,其他的示例包括:
{code:java}
// write some markup
render {
for(b in books) {
div(id:b.id, b.title)
}
}
// render a specific view
render(view:'show')
// render a template for each item in a collection
render(template:'book_template', collection:Book.list())
// render some text with encoding and content type
render(text:"<xml>some xml</xml>",contentType:"text/xml",encoding:"UTF-8")
{code}
发表评论
-
grails1.2中文文档即将发布
2009-11-10 11:25 2035grails1.2中文文档即将发布 发布日期可能与官方同步, ... -
我的桌面很酷吧
2009-03-31 17:19 1839我的桌面很酷吧 哈哈!!! 晒晒我的系统 -
Grails1.1中文文档——2009.3.25版本发布
2009-03-25 19:50 1558Grails1.1中文文档——2009.3.25版本修正了网友 ... -
对于Groovy&&Grails的问题大家可以在此提问
2009-03-23 12:06 1160如果大家碰到什么关于Groovy&&Grail ... -
Grails1.1中文文档正式发布
2009-03-19 22:58 1512经过大家的努力 Grails1.1中文文档正式发布 ... -
Grails 1.1中文文档即将发布
2009-03-11 16:50 1738Grails 1.1中文文档即将发布 SVN:http:/ ... -
现在支持对Groovy的代码高亮(有需要的可以找我)
2009-03-05 11:59 1445有需要的可以找我 -
groovy闭包 (PK) Java IOC
2008-10-17 15:03 2444N久没写东西,今天突发想法,写下来,废话少说,干活,先看几段代 ... -
grails and tinymce
2008-05-30 16:44 2286最近弄了个grails tinymce下的代码高亮插件: 界面 ... -
Grails中文文档beta发布
2008-05-08 21:32 2311经过我们大家的努力Grails中文文档终于面试了 下载抵制 b ... -
关于使用IDEA开发Grails项目乱码的问题
2008-04-10 02:40 3849关于Grails乱码的问题 个人测试了以后 还是属于编辑器的问 ... -
6.1.2 Controllers and Scopes
2008-03-18 23:39 1590h4. Available Scopesh4.可用范围(Sco ... -
6.1.1 Understanding Controllers and Actions
2008-03-18 23:16 1340h4. Creating a controllerh4. 创建 ... -
6.1 Controllers
2008-03-18 22:52 1305A controller handles requests a ... -
Groovy(Java笨狗)系列-Working with closures(1)
2008-03-17 22:28 1991翻译自《Groovy in action》 ... -
6.1.7 XML and JSON Responses
2008-03-09 15:19 3655h4. Using the render method to ... -
Grails(Java笨狗)系列-更好的理解闭包(closure)
2008-01-20 15:39 1939用现实生活中的示例来说明闭包 现在,让我们来考虑放在信封里的信 ... -
可能Grails的翻译不会在发布到BLOG中来了
2008-01-18 17:03 3278很荣幸能参加满江红的Grails的翻译 所以 Grails的翻 ... -
Grails(Java笨狗)系列--Configuration
2008-01-18 12:42 5228首先,Grails是一个信奉“规约重于配置”的框架,这一点是来 ... -
Groovy(Java笨狗)系列--fields and local variables
2008-01-14 16:28 4894使用最简单的术语,a variable(变量): 变量名引用的 ...
相关推荐
Rocky Linux 8.10内核包
内容概要:本文档详细介绍了如何在Simulink中设计一个满足特定规格的音频带ADC(模数转换器)。首先选择了三阶单环多位量化Σ-Δ调制器作为设计方案,因为这种结构能在音频带宽内提供高噪声整形效果,并且多位量化可以降低量化噪声。接着,文档展示了具体的Simulink建模步骤,包括创建模型、添加各个组件如积分器、量化器、DAC反馈以及连接它们。此外,还进行了参数设计与计算,特别是过采样率和信噪比的估算,并引入了动态元件匹配技术来减少DAC的非线性误差。性能验证部分则通过理想和非理想的仿真实验评估了系统的稳定性和各项指标,最终证明所设计的ADC能够达到预期的技术标准。 适用人群:电子工程专业学生、从事数据转换器研究或开发的技术人员。 使用场景及目标:适用于希望深入了解Σ-Δ调制器的工作原理及其在音频带ADC应用中的具体实现方法的人群。目标是掌握如何利用MATLAB/Simulink工具进行复杂电路的设计与仿真。 其他说明:文中提供了详细的Matlab代码片段用于指导读者完成整个设计流程,同时附带了一些辅助函数帮助分析仿真结果。
内容概要:该题库专为研究生入学考试计算机组成原理科目设计,涵盖名校考研真题、经典教材课后习题、章节题库和模拟试题四大核心模块。名校考研真题精选多所知名高校的计算机组成原理科目及计算机联考真题,并提供详尽解析,帮助考生把握考研命题趋势与难度。经典教材课后习题包括白中英《计算机组成原理》(第5版)和唐朔飞《计算机组成原理》(第2版)的全部课后习题解答,这两部教材被众多名校列为考研指定参考书目。章节题库精选代表性考题,注重基础知识与重难点内容,帮助考生全面掌握考试大纲要求的知识点。模拟试题依据历年考研真题命题规律和热门考点,精心编制两套全真模拟试题,并附标准答案,帮助考生检验学习成果,评估应试能力。 适用人群:计划参加研究生入学考试并报考计算机组成原理科目的考生,尤其是需要系统复习和强化训练的学生。 使用场景及目标:①通过研读名校考研真题,考生可以准确把握考研命题趋势与难度,有效评估复习成效;②通过经典教材课后习题的练习,考生可以巩固基础知识,掌握解题技巧;③通过章节题库的系统练习,考生可以全面掌握考试大纲要求的各个知识点,为备考打下坚实基础;④通过模拟试题的测试,考生可以检验学习成果,评估应试能力,为正式考试做好充分准备。 其他说明:该题库不仅提供详细的题目解析,还涵盖了计算机组成原理的各个方面,包括计算机系统概述、数据表示与运算、存储器分层、指令系统、中央处理器、总线系统和输入输出系统等。考生在使用过程中应结合理论学习与实践操作,注重理解与应用,以提高应试能力和专业知识水平。
__UNI__DB9970A__20250328141034.apk.1
rust for minio
国网台区终端最新规范
资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。
一个简单的机器学习代码示例,使用的是经典的鸢尾花(Iris)数据集,通过 Scikit-learn 库实现了一个简单的分类模型。这个代码可以帮助你入门机器学习中的分类任务。
pyqt离线包,pyqt-tools离线包
资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。
SQL常用日期和时间函数整理及在sqlserver测试示例 主要包括 1.查询当前日期GETDATE 2.日期时间加减函数DATEADD 3 返回两个日期中指定的日期部分之间的差值DATEDIFF 4.日期格式转换CONVERT(VARCHAR(10),GETDATE(),120) 5.返回指定日期的年份数值 6.返回指定日期的月份数值 7.返回指定日期的天数数值
GSDML-V2.3-Turck-BL20_E_GW_EN-20160524-010300.xml
T_CPCIF 0225-2022 多聚甲醛.docx
《基于YOLOv8的智能仓储货物堆码倾斜预警系统》(包含源码、可视化界面、完整数据集、部署教程)简单部署即可运行。功能完善、操作简单,适合毕设或课程设计
蚕豆脱壳机设计.zip
台区终端电科院送检文档
Y6一39一No23.6D离心通风机 CAD().zip
django自建博客app
台区终端电科院送检文档