为什么用tomcat启动之后,通过action访问会找不到路径

图一为用main方法直接运行,是没问题的。
img
图二为用tomcat启动,通过actino访问后就报找不到路径
img

部属到tomcat就不是src目录了呀,src目录只是你存放源代码的目录。

服务器访问路径就不对了 换成

string str = this.getClass().getClassLoader().getResource(folderName).getPath();