playframework文档未提及,但你能做的事
这里记录一些play!框架的文档未提及,但是可以做的一些事
playframe版本1.1
1.application.conf文件可以拆分
可以把application.conf文件拆成多个,需要在application.conf文件中加上@include.xxx=zzz.conf
xxx任意命名,xxx.conf放在conf目录下(与application.conf同一目录)
如:
application.conf
@include.site=mysite.conf
@include.hibernate=hibernate.conf
@include.hibernate_search=hibernate_search.conf
2.模版
在标签中,可以通过_caller.xxx引用控制器中render的对象
如:
public class My extends Controller{
public static void info(){
renderArgs.put("user",User.current());
render();
}
}
标签中这么引用:
_caller.user.username
3。在groovy模版吕,可以直接调用java类如:
%{
//需要全限类名
user = models.User.current()
}%
在routes中,可以使用标签,和调用方法如:
#{crud.types}
GET /? ${type.controllerClass.name.substring(12).replace('$','')}.index
GET /${type.controllerName} ${type.controllerClass.name.substring(12).replace('$','')}.list
GET /${type.controllerName}/new ${type.controllerClass.name.substring(12).replace('$','')}.blank
GET /${type.controllerName}/{id} ${type.controllerClass.name.substring(12).replace('$','')}.show
GET /${type.controllerName}/{id}/{field} ${type.controllerClass.name.substring(12).replace('$','')}.attachment
GET /${type.controllerName}/{id}/edit ${type.controllerClass.name.substring(12).replace('$','')}.edit
POST /${type.controllerName} ${type.controllerClass.name.substring(12).replace('$','')}.create
POST /${type.controllerName}/{id} ${type.controllerClass.name.substring(12).replace('$','')}.save
DELETE /${type.controllerName}/{id} ${type.controllerClass.name.substring(12).replace('$','')}.delete
#{/crud.types}
用纯java定义标签:如
//继承自FastTags,并定义命令空间
@FastTags.Namespace("lugua")
public class LuguaFastTag extends play.templates.FastTags{
public static final String PAGE_CACHE = "page-caches";
/**
* 缓存
* @param args
* @param body
* @param out
* @param template
* @param fromLine
*/
public static void _cache(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine){
String key = args.get("arg").toString();
String live = null;
if(args.containsKey("live")) {
live = args.get("live").toString();
}
Object cached = CacheManager.get(PAGE_CACHE,key);
if(cached != null) {
out.print(cached);
return;
}
String result = null;
if(body!=null)
result = JavaExtensions.toString(body);
CacheManager.set(PAGE_CACHE, key, result,live);
out.print(result);
}
}
使用方法跟普通的play标签一样
#{lugua.cache 'hotProduct','1h'}
<h1>热销产品</h1>
#{/}
http://www.anool.net/?p=182
playframework文档未提及,但你能做的事的更多相关文章
- (转载)Excel文档保存的时候,提示“文档未保存”
亲测,成功搞定 Excel文档保存的时候,提示“文档未保存”? 先打开你需要处理的excel,然后打开工具栏--宏--录制新宏--确定--停止录制宏--宏-宏--编辑--复制以下程序Sub 恢复保存( ...
- Html5 部分帮助文档 未完待续
W3cSchoolH5帮助文档 Video属性 视频播放效果 Video标签 src视频得目录 controls属性提供添加 播放 和音量控件 当然呢 不设置宽和高得话 视频会很大 Video还可以 ...
- WPS Office文档未保存怎么恢复
有时候用WPS Office时,文档还没保存,因为电脑卡死或者关机,再次打开时编辑的内容都不见了,这个时候可以利用WPS自带的备份功能来恢复文档,表格.幻灯片.文档都是可以的. 首先单击WPS左上角的 ...
- C# web项目利用docx文档作为模板~为打印专做的解决方案
还是那句话:十年河东,十年河西,莫欺少年穷. 目前,web端打印技术有很多,有收费的专业web打印控件,大家可以参考我的上一篇博客.当然,很多公司不愿意出钱,那么今天咱们就探讨下怎么做免费的打印. w ...
- ElasticSearch 5学习(8)——分布式文档存储(wait_for_active_shards新参数分析)
学完ES分布式集群的工作原理以及一些基本的将数据放入索引然后检索它们的所有方法,我们可以继续学习在分布式系统中,每个分片的文档是被如何索引和查询的. 路由 首先,我们需要明白,文档和分片之间是如何匹配 ...
- 理解MFC 文档、视图、框架[转]
理解文档/视图框架 出处.雷神 了解文档和视图的相互作用关系是编写MFC程序的基本功.但是MFC的应用程序框架把文档和视图之间 ...
- ElasticSearch(2)-文档
上一篇 ES(1) 官网原地址:https://www.elastic.co/guide/en/elasticsearch/reference/1.7/_cluster_health.html ES权 ...
- Kindle支持文档类型
Kindle支持文档类型 Kindle个人文档服务目前只能转换并发送以下类型的文档:Microsoft Word (.doc, .docx) RTF文件(.rtf) HTML(.htm, .html) ...
- Spring Boot 集成 Swagger 构建接口文档
在应用开发过程中经常需要对其他应用或者客户端提供 RESTful API 接口,尤其是在版本快速迭代的开发过程中,修改接口的同时还需要同步修改对应的接口文档,这使我们总是做着重复的工作,并且如果忘记修 ...
随机推荐
- python string.py 源码分析 三:maketrans
l = map(chr, xrange(256)) #将ascii转为字符串 _idmap = str('').join(l) del l # Construct a translation stri ...
- HTML5[7]: 实现网页版的加载更多
理所当然,jQuery出场: $(function() { $(window).scroll(function() { if($(this).scrollTop() + $(this).innerHe ...
- C#基础总结之二循环控制-运算符
#region 第二天 作业2 从键盘上输入三个数,用if语句和逻辑表达式把最小数找出来. //需要:控制台输入 三个变量(a,b,c)判断这三个数其中一个最小的值 打印输出 //Console.Wr ...
- smartjs - DataManager 场景示例分析 - 数据懒加载
发一张policy的参数图设置图: 场景1 - 数据的懒加载/延迟加载 在很多时候,为了提高网页的加载速度,减少不必要的开销,会将页面的数据拆分成几个部分,首先加载呈现可视区域内的数据,然后剩下来的会 ...
- `cocos2dx 非完整` UI解析模块
昨天在cocos2dx的一个群里,遇到一位匿名为x的朋友询问的问题,是关于ui的.他使用c++写了不少的ui封装节点,用来实现游戏中的各种不同效果.然后现在想改用lua,于是尝试使用最小代价去复用自己 ...
- mysql中int、bigint、smallint 和 tinyint的区别详细介绍
1 bytes = 8 bit ,一个字节最多可以代表的数据长度是2的8次方 11111111 在计算机中也就是 -128到127 1.BIT[M] 位字段类型,M表示每个值的位数,范围从1到64,如 ...
- [Python] Symbol Review
From:http://learnpythonthehardway.org/book/ex37.html 1. with X as Y: pass 1.1 yield 2. exec 2.1 name ...
- Flatic – 超齐全的 Web 元素界面素材库免费下载
Flatic 是一个庞大的用户界面工具包,包含数以百计的网页元素,这将有助于你在 Photoshop 中轻松设计整个网站.成套的图标和动作都已包含在套件中.该素材包包括超过100个 PSD 元素.您可 ...
- JS魔法堂:追忆那些原始的选择器
一.前言 ...
- [Tool] PLSQL使用技巧
1.PL/SQL Developer保存自定义界面布局 Tools->Preferences->User Interface->Options->Autosave deskto ...