Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我处于接缝 2。如何获取 servlet 上下文?
我可以这样做: ServletContexts servletContexts = ServletContexts.getInstance();
但这不是 ServletContext。
取决于您尝试获取的ServletContext时间:
ServletContext
在HttpServletRequest请求期间:ServletContexts.instance().getRequest().getServletContext()。
HttpServletRequest
ServletContexts.instance().getRequest().getServletContext()
在 JSF 请求期间:(ServletContext)FacesContext.getCurrentInstance().getExternalContext().
(ServletContext)FacesContext.getCurrentInstance().getExternalContext()
在应用程序启动期间:ServletLifecycle.getServletContext().
ServletLifecycle.getServletContext()
xslt 中的元素?