String newpath= "/img/system/other.png";
ExternalContext exContext = FacesContext.getCurrentInstance().getExternalContext();
HttpServletRequest request = (HttpServletRequest) exContext.getRequest();
File file = new File(request.getRealPath(newpath));
if(file.isFile)
{
...
}
ExternalContext exContext = FacesContext.getCurrentInstance().getExternalContext();
HttpServletRequest request = (HttpServletRequest) exContext.getRequest();
File file = new File(request.getRealPath(newpath));
if(file.isFile)
{
...
}
本文详细介绍了如何使用Java的FacesContext和ExternalContext获取HTTP请求的实际路径,并创建指定路径的文件。通过实例代码展示了从请求路径中提取信息并利用File类进行文件操作的过程。
1万+

被折叠的 条评论
为什么被折叠?



