jsf - 如何获取查询字符串

标签 jsf query-string

我正在使用 jsf 1.1 和 icefaces 1.8。我有一个 PartsInv.jsp 页面和一个托管 PartsInv.java bean。我试过根据我遇到的谷歌点击量来处理几个类,感觉我越来越接近了,但我不能完全确定它。这就是我所拥有的:

HttpServletRequestWrapper hsrw;
String rcVal = hsrw.getAttribute("rc").toString();

但当然hsrw没有正确实例化..我不太确定如何(或用什么包装它)。任何帮助,将不胜感激。

编辑 :根据 Jigar 的回答,我已将代码更新为以下内容:
    HttpServletRequest hsr = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

    if(hsr.getAttribute("rc") != null)
    {
        try
        {
            int rc = Integer.parseInt(hsr.getAttribute("rc").toString());
            this.SOM_RC.setValue(rc);
            this.changeRC(null);
        }
        catch(NumberFormatException nfe)
        {
            this.lblStatus.setValue("eASP error, please see an administrator.");
            return;
        }
    }

编辑 2:好的,所以我使用了错误的方法。 hsr.getParameter()有诀窍

最佳答案

对于 JSF 去

HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

关于jsf - 如何获取查询字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7339397/

相关文章:

java - <p :messages> summary and detail 中的重复文本

.htaccess - 没有 index.php 的查询字符串

javascript - 如何在 AngularJS 中将查询字符串附加到 url 中?

c# - Polly 在重试时更改查询字符串

c# - 如何使用 c# 从 asp.net 中的查询字符串中删除项目?

json - 带有查询字符串的 POST 嵌套对象

java.lang.IllegalStateException : Component javax. faces.component.UIViewRoot@19ded20 不是预期的类型

java - 有条件需要 a4j 形式的 jsf 验证

java - JSF:HtmlPanelGroup 中的子 ID 不正确(忽略 HtmlPanelGroupId)

JSF Primefaces - 如何突出显示当前选定的 p :menuitem.