0

我想在jsp文件中定义一个路径

<% String paths = "/test/abc.txt"; %>

但它总是向我显示 - 找不到文件错误
我正在使用 tomcat8 服务器和我的 index.jsp 文件放在同一级别的 txt 文件中,都在测试文件夹中。

webapps/test/index.jsp
webapps/test/abc.txt
4

1 回答 1

1

当您的路径在 webapp 上下文中时,请使用application.getRealPath("/")

<% String paths = application.getRealPath("/") + "abc.txt"; %>
于 2014-04-23T19:55:59.587 回答