Error getting file name using getServletConfig

前提是你 提交于 2019-12-02 07:08:47

The Path you give should be servlet path. Normally, servlets paths have forward slash /.

Please try this /rpts/report1.jasper".

Luiggi Mendoza

Java language (and others) needs \\ (double backslash) in Strings in order to read a single \. Your first way should change to

JasperReport report = (JasperReport) JRLoader.loadObject(getServletConfig()
    .getServletContext().getRealPath("\\rpts\\report1.jasper"))

Still, it would be better to check paths using / or even better using File#separator as shown here: File.separator vs Slash in Paths

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!