我知道如何申請對象在處理bean方法:在JSF2.x中,如何使用DI將請求對象傳遞給Managed Bean?
@ManagedBean
public class HomeAction {
....
public String getHtmlFormattedCookiesInfo(){
FacesContext facesCtx = FacesContext.getCurrentInstance();
ExternalContext extCtx = facesCtx.getExternalContext();
HttpServletRequest req = (HttpServletRequest) extCtx.getRequest();
....
// now do something with the req object such as read cookie
// or pass req object to another another function
// that knows nothing about JSF
....
}
}
}
但是,我不喜歡把人臉特定代碼在我的bean對象。
有沒有辦法使用DI和faces-config.xml傳遞請求?
Question number 9337433開始回答它,當你想傳遞請求對象上的東西。但是,我想要整個請求對象。