Tomcat 路径问题,弄不懂原因,请大家来帮我解决..

我现在用struts1+jasperreports 做报表,可是在应用中老是得不到正确的路径,请大家帮我看一下,谢谢
[code="java"]
public ActionForward lookAss(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws JRException {
String path = request.getContextPath();
String string = "C://Program Files//Apache Software Foundation//Tomcat 6.0//webapps//IRSSoftware//ireports//PDF.jrxml";

    String paths = System.getProperty("user.dir");
    System.out.println(paths);
    JasperDesign design = JRXmlLoader.load(string);
    return null;
}

[/code]

得到的结果是
[code="java"]
C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin

[/code]
晕了,怎样才能得到
[code="java"]
C://Program Files//Apache Software Foundation//Tomcat 6.0//webapps//IRSSoftware//ireports//PDF.jrxml

[/code]
这个路径呢
?

用this.getServlet().getServletContext().getRealPath("/")+"/ireports/PDF.jrxml"试试~~

你得到的是源文件的路径,而不是WEB应用的路径,建议试着查查这方面的东西,再调试调试~

使用request.getRealPath(“ireports//PDF.jrxml ”)方法,当然这个方法已经过时了,为了安全可以使用session提供的类似方法

可以把路径配置到配置文件里,然后读配置文件不就行了。