[英]Set confirmation link parameter in bean using PrettyFaces
I'm trying to send an email confirmation link in JSF 2.0. 我正在尝试在JSF 2.0中发送电子邮件确认链接。 The correct link is sending to the user's email without any problems, but I'm struggling to have the link redirect to the correct page when the user clicks on it.
正确的链接发送到用户的电子邮件没有任何问题,但是当用户单击链接时,我正努力将链接重定向到正确的页面。 I am trying to use pretty faces for URL mapping.
我正在尝试使用漂亮的面孔进行URL映射。
The confirmation link looks something like: 确认链接如下所示:
/confirm?param=1xfib3e
My code in pretty faces: 我的代码很漂亮:
<url-mapping id="confirm">
<pattern value="/confirm?param=#{ iid : emailConfirmation.param}" />
<action>#{emailConfirmation.confirmationLink}</action>
</url-mapping>
I've also tried changing { iid : emailConfirmation.param}
to {emailConfirmation.param}
and { param : emailConfirmation.param}
我还尝试将
{ iid : emailConfirmation.param}
更改为{emailConfirmation.param}
和{ param : emailConfirmation.param}
and I've tried 我已经尝试过
<url-mapping id="confirm">
<pattern value="/confirm" />
<query-param name="param">#{emailConfirmation.param}</query-param>
<action>#{emailConfirmation.confirmationLink}</action>
</url-mapping>
I also have a RequestScoped bean that looks something like: 我还有一个RequestScoped bean,看起来像:
@Named("emailConfirmation")
@RequestScoped
public class EmailConfirmation implements Serializable{
private String param;
....
public String confirmationLink() {
log("param value: " + param);
}
public String getParam() {
return param;
}
public void setParam(String param) {
this.param = param;
}
}
Whenever the user clicks on the link right now, the param value is null. 用户现在单击链接时,param值为null。 How is this caused and how can I solve it?
这是怎么引起的,我该如何解决?
Found the answer. 找到了答案。 If anyone is curious, it is because I had imported
如果有人好奇,那是因为我进口了
javax.faces.bean javax.faces.bean
instead of 代替
javax.enterprise.context.RequestScoped .... javax.enterprise.context.RequestScoped ....
Also, it was the second block of url mapping code that worked, not the first! 另外,它是起作用的第二个URL映射代码块,而不是第一个!
You cannot use query parameters in the <pattern>
part of the mapping. 您不能在映射的
<pattern>
部分中使用查询参数。 If you want to configure query parameters for a mapping, use something like this: 如果要为映射配置查询参数,请使用以下命令:
<url-mapping id="confirm">
<pattern value="/confirm" />
<query-param name="param">#{emailConfirmation.param}</query-param>
<action>#{emailConfirmation.confirmationLink}</action>
</url-mapping>
See: 看到:
http://www.ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/Configuration.html#config.queryparams http://www.ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/Configuration.html#config.queryparams
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.