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

apache的开源项目-模板引擎(Velocity)_学习了两天就上手啦_源码

发布时间:2020-12-14 06:29:31 所属栏目:Java 来源:网络整理
导读:首先,如果你对Velocity不是很了解,还是建议你去apache的官方网站上去走走.... 这是velocity的官网: 当然如果你对英文文档不是很感冒,这里也有好的资料: 下面我就正式说说我做的项目啦... String HELLO_WORLD_VM_PATH = "vms/helloWorld.vm" String USER

首先,如果你对Velocity不是很了解,还是建议你去apache的官方网站上去走走....

这是velocity的官网:

当然如果你对英文文档不是很感冒,这里也有好的资料:

下面我就正式说说我做的项目啦...

String HELLO_WORLD_VM_PATH = "vms/helloWorld.vm" String USER_INFO_VM_PATH = "vms/userInfo.vm" String EMAIL_TEMPLATE_VM_PATH = "vms/emailTemplate.vm" main(String[] args) sayHelloFromVM(String fileVM) VelocityEngine ve = Template t = VelocityContext context = context.put("hello","Hello world!!" StringWriter writer = testUser(String fileVM) VelocityEngine ve = Template template = VelocityContext velocityContext = User user = user.setEmail("hongtenzone@foxmail.com" user.setName("hongten" user.setBirthday("1990-11-18" velocityContext.put("user" StringWriter stringWriter = testEmail(String fileVM) VelocityEngine velocityEngine = Template template = VelocityContext velocityContext = Mail mail = mail.setContent("2013年腾讯开发者新扶持政策解读及创业机会所在" mail.setReceiverMail("hongtenzone@foxmail.com" mail.setReceiverName("Hongten" mail.setSenderMail("opensns_noreply@tencent.com" mail.setSenderName("腾讯开放平台" mail.setSenderWebSite("open.qq.com" SimpleDateFormat simpleDateFormat = "yyyy-MM-dd HH:mm:ss" mail.setDate(simpleDateFormat.format( velocityContext.put("mail" StringWriter stringWriter = }

.id = .name = .password = .birthday = .email = }

.id = .senderName = .senderMail = .receiverName = .receiverMail = .content = .date = .senderWebSite = }

##test hello world! $hello

A: what A: what A: what A: good!

Sender : $mail.senderName<$mail.senderMail> Receiver : $mail.receiverName<$mail.receiverMail> please quick login the $mail.senderWebSite message center

<div class="cnblogs_code">

 # ----------------------------------------------------------------------------
  # ----------------------------------------------------------------------------
 
 input.encoding=ISO-8859-1
 output.encoding=ISO-8859-1

VelocityEngine velocityEngine = velocityEngine.setProperty("input.encoding","UTF-8" velocityEngine.setProperty("output.encoding","UTF-8" velocityEngine.init();

(编辑:李大同)

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

    推荐文章
      热点阅读