我正在使用 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/