加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

play 标签

发布时间:2020-12-14 16:43:57 所属栏目:大数据 来源:网络整理
导读:**play 可以直接应用于页面及页面js代码中,所有标签#{}开始,以#{/}结束,注释使用*{注释文本}* ** 链接服务器路由:链接到router表中对应的路由 #{a @Application.index()}首页#{/a} a href=“@{Application.index()}”首页/aa href=“application/index”

**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()}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读