星空网 > 软件开发 > Java

Play Framework 完整实现一个APP(五)

程序以及基本可用了,需要继续完善页面

 

1.创建页面模板

创建文件 app/views/tags/display.html 

*{ Display a post in one of these modes: 'full', 'home' or 'teaser' }* <div >  <h2 >    <a href="#">${_post.title}</a>  </h2>  <div >    <span >by ${_post.author.fullname}</span>,    <span >${_post.postedAt.format('dd MMM yy')}</span>    #{if _as != 'full'}      <span >         |  ${_post.comments.size() ?: 'no'}         comment${_post.comments.size().pluralize()}        #{if _post.comments}          , latest by ${_post.comments[0].author}        #{/if}      </span>    #{/if}  </div>  #{if _as != 'teaser'}    <div >      <div >Detail: </div>      ${_post.content.nl2br()}    </div>  #{/if}</div> #{if _as == 'full'}  <div >    <h3>      ${_post.comments.size() ?: 'no'}       comment${_post.comments.size().pluralize()}    </h3>        #{list items:_post.comments, as:'comment'}      <div >        <div >          <span >by ${comment.author},</span>          <span >            ${comment.postedAt.format('dd MMM yy')}          </span>        </div>        <div >          <div >Detail: </div>          ${comment.content.escape().nl2br()}        </div>      </div>    #{/list}      </div>#{/if}

  

  

修改index.html

#{extends 'main.html' /}#{set title:'Home' /} #{if frontPost}    #{display post:frontPost, as:'home' /}    #{if olderPosts.size()}      <div >      <h3>Older posts <span >from this blog</span></h3>          #{list items:olderPosts, as:'oldPost'}        #{display post:oldPost, as:'teaser' /}      #{/list}    </div>      #{/if}  #{/if} #{else}  <div >    There is currently nothing to read here.  </div>#{/else}

  

  

2.修改Layout  views\main.html

<!DOCTYPE html><html>  <head>    <title>#{get 'title' /}</title>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>    <link rel="stylesheet" type="text/css" media="screen" href="@{'/public/stylesheets/main.css'}">    <link rel="shortcut icon" type="image/png" href="@{'/public/images/favicon.png'}">  </head>  <body>    <div id="header">      <div id="logo">        yabe.      </div>      <ul id="tools">        <li>          <a href="#">Log in to write something</a>        </li>      </ul>      <div id="title">        <span >About this blog</span>        <h1><a href="#">${blogTitle}</a></h1>        <h2>${blogBaseline}</h2>      </div>    </div>        <div id="main">      #{doLayout /}     </div>         <p id="footer">      Yabe is a (not that) powerful blog engine built with the       <a href="http://www.playframework.org">Play framework</a>      as a tutorial application.    </p>  </body></html>

  

3. Application.java 中添加方法,在页面上添加元素

@Beforestatic void addDefaults() {	renderArgs.put("blogTitle", Play.configuration.getProperty("blog.title"));	renderArgs.put("blogBaseline", Play.configuration.getProperty("blog.baseline"));}

添加渲染 blog.title blog.baseline

 

4.修改配置文件 conf\application.conf

# Blog engine configuration# ~~~~~blog.title=Yet another blogblog.baseline=We won't write about anything

  

5.添加页面样式

CSS: http://play-framework.herokuapp.com/zh/files/main.css

添加到 /public/stylesheets/main.css

 

运行效果:

Play Framework 完整实现一个APP(五)

 

 

 

..




原标题:Play Framework 完整实现一个APP(五)

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

跨境大卖致欧家居10000平米英国舱正式投入使用:https://www.kjdsnews.com/a/699104.html
深圳大卖跨境通申请破产清算被受理:https://www.kjdsnews.com/a/699105.html
跨境电商亚马逊精细化运营思路:https://www.kjdsnews.com/a/700097.html
2021俄罗斯电商总额增长或放缓:https://www.kjdsnews.com/a/700098.html
市场观察| Z世代年轻消费群体对环保的“真心”:https://www.kjdsnews.com/a/700099.html
沃尔玛美国站商品详情⻚优化指导:https://www.kjdsnews.com/a/700100.html
去日本入住酒店,东西随意用却有一个特殊“要:https://www.vstour.cn/a/411241.html
中国有哪些著名的酒店品牌。:https://www.vstour.cn/a/411242.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流