简体   繁体   English

如何使用SpringMVC读取tomcat 7文件夹中的文件

[英]How to read a file in tomcat 7 folder using SpringMVC

I have a quick question and wonder if anyone has come across this issue before? 我有一个快速的问题,想知道以前是否有人遇到过这个问题?

I am trying to read a file from my classpath into a .jsp with spring but I keep getting a 404 even when the url is correct. 我正在尝试使用spring将类路径中的文件读取到.jsp文件中,但是即使URL是正确的,我仍然会收到404。

eg 例如

/var/lib/tomcat7/webapps/ROOT/WEB-INF/classes/file/MyProcess.bpmn /var/lib/tomcat7/webapps/ROOT/WEB-INF/classes/file/MyProcess.bpmn

The file is available in the browser from the above url but not through the .jsp in the Spring Framework where a 404 (Not Found)is returned. 该文件可从上面的URL在浏览器中找到,但不能通过 Spring框架中的.jsp返回404(未找到)。

Has anyone come across this problem before? 有人遇到过这个问题吗?

You have to move your file out of the WEB-INF directory I think because it won't be accessible from your jsp page. 我认为您必须将文件移出WEB-INF目录,因为无法从jsp页面访问该文件。

This link should be useful 该链接应该有用

What is WEB-INF used for in a Java EE web application? Java EE Web应用程序中使用WEB-INF是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM