1
要從JSF 2.0 Managed Bean的操作處理程序通過一個隱藏的參數到Servlet,我傳遞參數值到一個會話屬性:我可以使用JSF flash將參數傳遞給Servlet嗎?
public void callServlet(long id) {
try {
ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
HttpSession sess = (HttpSession) ctx.getSession(false);
sess.setAttribute("id", id);
ctx.redirect("MyServlet");
} catch (IOException ex) {
Logger.getLogger(ResultBean.class.getName()).log(Level.SEVERE, null, ex);
}
}
是否有更好的方法來做到這一點,例如是否有可能使用閃存映射發送這個隱藏的參數到Servlet?