Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在jsp文件中定义一个路径
<% String paths = "/test/abc.txt"; %>
但它总是向我显示 - 找不到文件错误 我正在使用 tomcat8 服务器和我的 index.jsp 文件放在同一级别的 txt 文件中,都在测试文件夹中。
webapps/test/index.jsp webapps/test/abc.txt
当您的路径在 webapp 上下文中时,请使用application.getRealPath("/"):
application.getRealPath("/")
<% String paths = application.getRealPath("/") + "abc.txt"; %>