我的'src/main/recources'文件夹中有不同的XML文件,我想从我的webapplication中读取它们.
File f = new File("file1.xml");
f.getAbsolutePath();
Run Code Online (Sandbox Code Playgroud)
代码在WebService中调用,当我查看Tomcat-server-output时,会打印出'C:\ Users\Administrator'.我目前的解决方案是将'file1.xml'文档放在WAR之外的'C:\' - 文件夹中,但这样我的WAR不可转让.
我也试过了
<bean name="webService">
<property name="document">
<value>classpath:file1.xml</value>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
但这只是打印出"classpath:file.xml"而不解析它.
此致,皮特