Is there a way to get a resource in a spring web application using a simple Resource? I am trying not to pass any context, and need to obtain a file from the WEB-INF/freemarker/email/ directory.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. Since the
WEB-INF/freemaker/emailis not on the classpath, you need to passServletContext. As you mentionResource, you can use:Just don’t pass the
ServletContextto the service layer. Pass theResourceinstead.If you want to obtain the template from the classpath, place it there. That is, for example, in:
Then you can use
ClassPathResource