Java FacesContext getRequestParameter 不起作用
我在两台不同的机器上有相同的代码。一个在工作,另一个没有!代码在这里...你能发现我错过了什么吗?
public void urlParameters() {
FacesContext context = FacesContext.getCurrentInstance();
Map<String, String> paramMap = context.getExternalContext().getRequestParameterMap();
requestID = paramMap.get("id");
if (requestID.equals("1")) {
message = "right!!";
} else {
message = "Wrong!";
}
}
我通过以下链接访问它:
http://localhost:8080/SMDRepair/faces/review.xhtml?id=1
I've got the same code on two different machines. One is working the other isn't! The code is here... Anything you could spot that I missed?
public void urlParameters() {
FacesContext context = FacesContext.getCurrentInstance();
Map<String, String> paramMap = context.getExternalContext().getRequestParameterMap();
requestID = paramMap.get("id");
if (requestID.equals("1")) {
message = "right!!";
} else {
message = "Wrong!";
}
}
and I access it with this link:
http://localhost:8080/SMDRepair/faces/review.xhtml?id=1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过长时间的研究,我找到了在 JSF Bean 中获取 URL 参数的最简单方法:
只需确保导入:
希望这对将来有帮助
After long long long research, I found the simplest mean of getting URL parameter in JSF Bean:
Just make sure you import:
Hope this helps in future