FacesContext每个线程的实例都是唯一的,并且 The在请求的开头FacesServlet创建 a ThreadLocal<FacesContext>,同时获取(这是与 HTTP servlet 请求关联的响应FacesContext的合同 并在结束时将其删除(通过调用)。FacesContextFactory#getFacesContext)FacesContext#release
每当您FacesContext#getCurrentInstance()在 JSF 代码中执行操作时,您将始终在整个 HTTP servlet 请求/响应处理过程中获得相同的实例。
关于该方法UIViewRoot#processDecodes,我真的没有看到任何可能表明该方法使用它自己创建的实例而不是传递的实例的行。哪条线让你这么想?
可以在FacesServlet#service它创建FacesContextfrom The的方法中看到,这里是显示这一点FacesContextFactory的方法的摘录-FacesServlet#service
// Acquire the FacesContext instance for this request
FacesContext context = facesContextFactory.getFacesContext
(servletConfig.getServletContext(), request, response, lifecycle);
// Execute the request processing lifecycle for this request
try {
...
} catch (FacesException e) {
...
}
finally {
// Release the FacesContext instance for this request
context.release();
}
考虑到这一点,我觉得UIViewRoot#processDecodes不能拥有FacesContext不是 from 的实例FacesContextFactory。
既然你说 - 你已经设置了一些额外的参数来FacesContext返回FacesContextFactory,这意味着你有你自己的自定义实现FacesContextFactory,如果是这种情况,那么你确定你的实例是注入FacesServlet而不是 mojarra 的com.sun.faces.context.FacesContextFactoryImpl(如果你正在使用mojarra)?