我正在尝试访问 jsf 托管 bean 中的 example/web 文件夹(见下图),但似乎无法找到实现它的方法
谢谢
最佳答案
尝试
FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath()
用于构建应用中资源的相对 URL。
如果你想要真正的路径...
ServletContext ctx = (ServletContext) FacesContext.getCurrentInstance()
.getExternalContext().getContext();
String realPath = ctx.getRealPath("/");
关于java - 在 JSF 托管 Bean 中检索 Web 应用程序根路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10377643/