我正在使用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;
}
}
EDIT2:好了,我使用了錯誤的方法。 hsr.getParameter()
的伎倆
非常感謝!我欠你一個;) –
歡迎您也考慮麥道的 –