简体   繁体   English

春季-applicationContext.xml中的路径

[英]Spring - Paths in applicationContext.xml

I am defining a freemarker bean in my applicationContext.xml and this bean needs a path to my template-directory. 我在我的applicationContext.xml中定义了一个freemarker bean,这个bean需要到我的template-directory的路径。 It used to be: 它曾经是:

src/main/webapp/template/

But i now want to store my templates under: 但是我现在想将模板存储在以下位置:

src/main/resources/template/

It used to look like: 它过去看起来像:

<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
    <property name="templateLoaderPath" value="/template/email/"/>
</bean>

Can anyone please help me to correctly define the new path? 谁能帮我正确定义新路径吗?

Answering as a proper answer, so you can close the question. 回答为正确答案,这样您就可以结束问题。

You should use "classpath:" prefix to reference resources located in the classpath. 您应该使用“ classpath:”前缀来引用位于类路径中的资源。

<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
    <property name="templateLoaderPath" value="classpath:/template/email/"/>
</bean>

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

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