【发布时间】:2012-01-01 06:28:24
【问题描述】:
为了将隐藏参数从 JSF 2.0 托管 BEan 操作处理程序传递给 Servlet,我将参数值传递给 Session 属性:
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);
}
}
是否有更好的方法来做到这一点,例如是否可以使用 flash map 将这个隐藏参数发送到 Servlet?
【问题讨论】: