4
我在接縫2.如何獲取servlet上下文?Seam 2,如何獲取servletcontext?
我可以這樣做: ServletContexts servletContexts = ServletContexts.getInstance();
但這不是ServletContext。
我在接縫2.如何獲取servlet上下文?Seam 2,如何獲取servletcontext?
我可以這樣做: ServletContexts servletContexts = ServletContexts.getInstance();
但這不是ServletContext。
根據你正在試圖獲得ServletContext
什麼時刻:
在一個HttpServletRequest
要求:ServletContexts.instance().getRequest().getServletContext()
。
在JSF請求期間:(ServletContext)FacesContext.getCurrentInstance().getExternalContext()
。
在應用程序啓動過程中:ServletLifecycle.getServletContext()
。
應該是'FacesContext.getCurrentInstance()' –
@KirillBazarov,你是對的!我更新了答案:) – Tair