手机版
你好,游客 登录 注册
背景:
阅读新闻

Java中如何使用freemaker模版进行输出

[日期:2013-03-06] 来源:Linux社区  作者:chiweitree [字体:大 中 小]

在Java中如何使用freemaker模版进行输出呢?

首先你要有一个定义好的ftl文件,也就是最终输出的样式定义

<html>
<head>
<title></title>
</head>
<style type="text/css">

table {
 width: 800px;
 height: 400px;
 border: 2px solid black;
}

table thead tr td{
 text-align: center;
 border-right: 1px solid #C1DAD7;
 border-bottom: 1px solid #C1DAD7;
 background: #fff;
 font-size: 20px;
 font-weight: bold;
 color: #4f6b72;
}

.td1 {
 border-right: 1px solid #C1DAD7;
 border-bottom: 1px solid #C1DAD7;
 background: #fff;
 font-size: 14px;
 padding: 6px 6px 6px 12px;
 color: #4f6b72;
 width: 100px;
}

.td2 {
 border-right: 1px solid #C1DAD7;
 border-bottom: 1px solid #C1DAD7;
 background: #fff;
 font-size: 14px;
 padding: 6px 6px 6px 12px;
 color: #4f6b72;
 width: 500px;
}

</style>
<body>
 <center>
  <table>
   <thead>
    <tr>
     <td colspan='2'>AlertMail</td>
    </tr>
   </thead>
   <tr>
    <td class="td1">Mon_type</td>
    <td class="td2">${AM.monType}</td>
   </tr>
   <tr>
    <td class="td1">Alert_code</td>
    <td class="td2">${AM.alertCode}</td>
   </tr>
   <tr>
    <td class="td1">Alert_text</td>
    <td class="td2">${AM.alertText}</td>
   </tr>
   <tr>
    <td class="td1">Mon_date</td>
    <td class="td2">${AM.monDate}</td>
   </tr>
  </table>
 </center>
</body>
<html>

linux
相关资讯       freemaker 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款