//需要获取WebRoot下面的文件使用如下方法 String url = super.getServletContext().getRealPath("/")+"test/studentinfo.xml"; //WebRoot