我的xml文件 是和jsp文件放在一起,是放在WebRoot目录下有用jdom读取的时候,路径提示不对,我应该怎么写
SAXBuilder sb=new SAXBuilder();
Document doc=sb.build("NetCall.xml");

解决方案 »

  1.   

    Document doc=sb.build("D:/xxx/xxx/NetCall.xml");或者用 request.getSession().getServletContext().getRealPath("/") 得到绝对路径
      

  2.   

    request.getSession().getServletContext().getRealPath("/")得到绝对路径
    或者直接放在src根目录下直接sb.build("NetCall.xml");
      

  3.   

    使用相对路径是最好的解决方案了。在jsp文件中获得路径
    getServletContext().getRealPath("/NetCall.xml")
      

  4.   

    request.getSession().getServletContext().getRealPath("/")得到绝对路径 就行啦