小技巧:在管理Bean中获得当前视图(JSP页面)URL中提交的参数的方法。
这种方式适用于无边界任务流和右边界任务流,在进入任务流页面的时候提交,注意页面相互跳转期间参数会丢失,所以建议将管理Bean的生命周期设定为页面流(PageFlow),在管理Bean的构造方法中进行参数获取。。
例如:abc.jspx?name=test
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = ((HttpServletRequest)
context.getExternalContext().getRequest());
String name = request.getParameter("name");
if (name == null) {
name = "def";
}
System.out.println("URL name="+name);
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。