[英]Accessing an ftl file under WEB-INF in a Java Project in eclipse
I am using Eclipse Neon.2 Release (4.6.2)
for my Java Spring MVC Web Application
. 我将Eclipse Neon.2 Release (4.6.2)
用于Java Spring MVC Web Application
。 I am trying to access an ftl file placed in a subfolder under WEB-INF
and read its value to a string. 我试图访问放置在WEB-INF
下的子文件夹中的ftl文件,并将其值读取为字符串。 I am using the following code: 我正在使用以下代码:
Resource resource = new ClassPathResource("/src/main/webapp/WEB-INF/jsp/modules/abc/sub1/sub2/message.ftl");
InputStream resourceInputStream = resource.getInputStream();
String message = IOUtils.toString(resourceInputStream, "UTF-8");
But I am getting a file not found exception. 但是我收到一个文件未找到异常。 The exact path of the file is /my-project/src/main/webapp/WEB-INF/jsp/modules/abc/sub1/sub2/message.ftl
文件的确切路径是/my-project/src/main/webapp/WEB-INF/jsp/modules/abc/sub1/sub2/message.ftl
How can I read the contents of that file to a string. 如何将文件的内容读取为字符串。
the path should be /WEB-INF/jsp/modules/abc/sub1/sub2/message.ftl
. 路径应为/WEB-INF/jsp/modules/abc/sub1/sub2/message.ftl
。 src/main/whatever
is a maven convention, your container doesn't know anything about it. src/main/whatever
是什么Maven约定,您的容器对此一无所知。
The war file deployed in the container will not have any src/main/*
部署在容器中的war文件将没有任何src/main/*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.