如何在jsf2中添加请求参数? [英] How to add request parameter in jsf2?

查看:66
本文介绍了如何在jsf2中添加请求参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,在升级到jsf 2之前,执行自定义重定向时,我曾手动将带有特定值的请求参数放在外部上下文中,如下所示:

In my app, before upgrading to jsf 2, when doing a custom redirect I used to manually put a request parameter with a specific value in external context like this:

FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()
                .put(CmwNavigationControllerBean.PARAM_DISPLAY_TARGET_POPUP, "true");

现在,此行将引发异常,因为似乎不再允许修改此地图:

Now this line, throws an exception because it seems that this map is no longer allowed to be modified:

at java.util.Collections$UnmodifiableMap.put(Unknown Source) [rt.jar:1.7.0]

不是真的没有其他方法可以绕过此异常吗?由于升级,我正在进行重构,因此我尝试将更改保持在最低水平.

Isn't really no other way to bypass this exception? I'm doing refactoring because of upgrade and I try to keep the changes at minimal level.

推荐答案

而不是ExternalContext上的javax/faces/context/ExternalContext.html#getRequestMap%28%29"rel =" nofollow> getRequestMap().

Rather than getRequestParameterMap() (which is read-only) you should invoke getRequestMap() on the ExternalContext.

例如:

FacesContext.getCurrentInstance()
            .getExternalContext()
            .getRequestMap()
            .put(CmwNavigationControllerBean.PARAM_DISPLAY_TARGET_POPUP, "true");

这篇关于如何在jsf2中添加请求参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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