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にいます。サーブレットコンテキストを取得するにはどうすればよいですか?
私はこれを行うことができます: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()