play 标签

**play 可以直接应用于页面及页面js代码中,所有标签#{}开始,以#{/}结束,注释使用*{注释文本}* **

  • 链接服务器路由:链接到router表中对应的路由
#{a @Application.index()}首页#{/a} 
<a href=“@{Application.index()}”>首页</a>
<a href=“application/index”>首页</a>
  • authenticityToken: 用来生成一个包含token信息的可以放到任何form的隐藏域,用来防止跨站点的请求伪造攻击。后台form提交路由函数中直接调用checkAuthenticity(),校验不通过会跳转到默认的错误页面。
#{authenticityToken /} 
<input type="hidden" name="authenticityToken" value="1c6d92fed96200347f06b7c5e1a3a28fa258ef7c">   
  • doLayout: 模板继承标签,子元素通过#{extends '父元素相对路径'/}来进行页面的嵌套
<!--父页面文件common/common.html-->
<div class="container">
    <div class="header">头部</div>
    <!--此处用来引用子页面,类似jsp中的include标签-->
    #{doLayout /}
    <div class="footer">底部</div>
</div>
  • extends:继承父标签
<!--子页面front/index.html-->
#{extends 'common/common.html' /}
<div class="child">子页面内容区</div>
  • if...else:用来在页面中进行逻辑判断,if可单用也可配合使用,可用页面js中
#{if user==null}登录#{/if}
#{elseif user!=null && !user?.auther}认证#{/elseif}
#{else}登录成功#{/else}
  • list:用来迭代后台集合数据,items指定集合数据,as指定别名
#if{userList!=null && userList.size()>0}
#{list items:userList,as:'user'}
    <tr>
        <td>${user_index}</td>//本次迭代的索引值
        <td>${(page?.currPage - 1)*page?.pageSize+_index}</td>//分页数据中的索引值
        <td>${user?.name}</td>
        ...
    </tr>
#{/list}
#{/if}
或者
#if{userList!=null && userList.size()>0}
#{list items:userList}
    <tr>
        <td>${user_index}</td>//本次迭代的索引值
        <td>${(page?.currPage - 1)*page?.pageSize+_index}</td>//分页数据中的索引值
        <td>${_?.name}</td>
        ...
    </tr>
#{/list}
#{/if}
  • %{}:代码块,可用来直接编写源代码,可直接在页面${}引用
%{utils.DateUtils date = new utils.DateUtils();}%
<h1>${date?.currentTime()?.format('yyyy-MM-dd HH:mm:ss')</h1>
<h1>${constants.Constants.money?.format('###,##0.00')}</h1>
<h1>${constants.Constants.money?.formatCurrency('CNY')}</h1>

输入图片说明

  • get|set
#{set title:'标题'/}
#{get 'title'/}
  • @{‘’}:静态资料导入标签
<link href="@{'/public/stylesheets/main.css'}" rel="stylesheet">
  • form:表单
#{form @login(), method:'POST', id:'sub'} #{/form}
<form action="/indexaction/login?x-http-method-override=POST" method="post" accept-charset="utf-8" enctype="application/x-www-form-urlencoded" id="sub">
<input type="hidden" name="authenticityToken" value="84aec43e817adbb56496c312236b1e49ad250efd">
</form>
  • include:类似jsp中的include标签
#{include 'Application/index.html'/}

----------------------------------------标签内置函数----------------------------

  • format:格式化日期、金额等
${money?.format('###,##0.00')}
${money?.formatCurrency('CNY')}
${date?.format('yyyy-MM-dd HH:mm:ss')}
  • raw:以html格式显示
${content?.raw()}

https://www.fank243.com/posts/31b22b29.html

转载于:https://my.oschina.net/skyAcross/blog/686887

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值