日期:2014-05-16  浏览次数:20395 次

JSF下,获得项目根路径
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)
{
...
}