FileInputStream and FileNotFound Exception

后端 未结 5 2009
慢半拍i
慢半拍i 2021-01-28 11:05

I am trying to retrieve a jrxml file in a relative path using the following java code:

 String jasperFileName = \"/web/WEB-INF/reports/MemberOrderListReport.jrxm         


        
5条回答
  •  轮回少年
    2021-01-28 11:56

    String jasperFileName = "/web/WEB-INF/reports/MemberOrderListReport.jrxml";
    

    Simple. You don't have a /web/WEB-INF/reports/MemoberOrderListReport.jrxml file on your computer.

    You are clearly executing in a web-app environment and expecting the system to automatically resolve that in the context of the web-app container. It doesn't. That's what getRealPath() and friends are for.

提交回复
热议问题