Retrieve the web app root path in JSF Managed Bean

后端 未结 4 1727
梦谈多话
梦谈多话 2021-01-02 08:50

Im trying to access the example/web folder (see below in the image) in a jsf managed bean but cant seem to find a way to do it

4条回答
  •  长发绾君心
    2021-01-02 09:38

    Try:

    String relativePath="/resources/temp/";
    String absolutePath=   FacesContext.getCurrentInstance.getExternalContext().getRealPath(relativePath);
    File file = new File(absolutePath);
    

    to get real path.

    Create a tmp file in resources/temp/ to avoid any exception.

提交回复
热议问题