如何将get请求参数传递给我的Velocity模板以发送邮件 [英] How do I pass get request parameters to my Velocity Template to send mails

查看:114
本文介绍了如何将get请求参数传递给我的Velocity模板以发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSP,在那个JSP中,我有一个看起来像

I have a JSP and in that JSP I have a link which looks something like

http://mydomain.com/verify.do?email=emailid& id = 123

现在,当用户单击该链接时,它会转到我的VelocityView Servlet,现在我的问题是如何在Velocity Servlet中提取这些参数并将其放入上下文中,以便可以将其发送到我的模板中.

Now when users clicks that link, it goes to my velocityview servlet, now my question is how do I pull out those parameters in velocity servlet and put it into the context so that I can send it to my template.

我尝试了getparameter,#set(#request.getAttribute(email)等.但是由于某种原因,我看不到该值进入上下文或模板.

I tried getparameter,#set(#request.getAttribute(email) etc.But for some reason I dont see the value getting into the context or template.

我知道那里有速度参数工具,但是我找不到如何安装和使用它的方法.因此,如果有人能指出我正确的方向,请多加赞赏.

I know there is velocity parameter tool out there,but I am not able to find as how to install and use it.So appreciate if someone can point me to right direction.

推荐答案

解决方案是

The solution is the Velocity context. In your backing Java class or Velocity servlet, read in the parameters and put them in the context:

context.put("email", request.getParameter("email"));
context.put("id", request.getParameter("id"));

然后在Velocity模板中,可以将它们引用为$email$id.

Then in your Velocity template you can reference them as $email and $id.

这篇关于如何将get请求参数传递给我的Velocity模板以发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆