Freemarker TemplateLoader.findTemplateSource("WEB-INF/template/index.html"): Not found错误原因
2017-10-27 16:57
811 查看
Spring配置文件如下:
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/tpl/" />
<property name="freemarkerSettings">
<props>
<prop key="template_update_delay">0</prop>
<prop key="default_encoding">UTF-8</prop>
<prop key="number_format">0.##########</prop>
<prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
<prop key="classic_compatible">true</prop>
<prop key="template_exception_handler">rethrow</prop>
<prop key="auto_import">/common/spring.ftl as spring</prop>
</props>
</property>
</bean>如果Spring的配置文件已经添加templateLoaderPath,SpringMVC中的Freemarker配置中的prefix不需要再进行配置或者留空就可以,否则就会报TemplateLoader.findTemplateSource("/WEB-INF/template/index.html"): Not found
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/tpl/" />
<property name="freemarkerSettings">
<props>
<prop key="template_update_delay">0</prop>
<prop key="default_encoding">UTF-8</prop>
<prop key="number_format">0.##########</prop>
<prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
<prop key="classic_compatible">true</prop>
<prop key="template_exception_handler">rethrow</prop>
<prop key="auto_import">/common/spring.ftl as spring</prop>
</props>
</property>
</bean>如果Spring的配置文件已经添加templateLoaderPath,SpringMVC中的Freemarker配置中的prefix不需要再进行配置或者留空就可以,否则就会报TemplateLoader.findTemplateSource("/WEB-INF/template/index.html"): Not found
<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> <property name="cache" value="false" /> <property name="prefix" value="" /> <property name="suffix" value=".html" /> <property name="contentType" value="text/html;charset=UTF-8"></property> <property name="requestContextAttribute" value="request" /> <property name="exposeSpringMacroHelpers" value="true" /> <property name="exposeRequestAttributes" value="true" /> <property name="exposeSessionAttributes" value="true" /> </bean>
相关文章推荐
- Can not find the tag library descriptor for "/WEB-INF/struts-html.tld"报错
- Spring mvc 中使用ftl引用共通文件出错 FreeMarker template error: Error reading included file "/WEB-INF/ftl/common/errormessage.ftl"
- Spring Boot Did not find handler method for [/WEB-INF/views/index.html]
- Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin' 【Webpack错误】
- VSS出项错误"Could not find the Visual SourceSafe Internet Web Service connection..."
- ResourceManager : unable to find resource '/yicheng/index.html.vm' in any resource loader.
- HTTP错误404.13 - Not Found 请求筛选模块被配置为拒绝超过请求内容长度的请求,原因是Web服务器上的请求筛选被配置为拒绝该请求,因为内容长度超过配置的值
- VSS出错"Could not find the Visual SourceSafe Internet Web Service connection..."
- freemarker.core.ParseException: Parsing error in template "site/product/solid/showSolid.html" in li
- <%@ page language="C#" autoeventwireup="true" inherits="index, App_Web_vsb3n 生成网站后,发布到网站上就提示这个错误
- Android错误之"source not find"
- VSS出错"Could not find the Visual SourceSafe Internet Web Service connection..."
- HTTP错误404.13 - Not Found 请求筛选模块被配置为拒绝超过请求内容长度的请求,原因是Web服务器上的请求筛选被配置为拒绝该请求,因为内容长度超过配置的值(IIS 7 默认文件上传大
- jsp出现错误can not find the tag directory /web-inf/tags
- VSS出错"Could not find the Visual SourceSafe Internet Web Service connection..."
- jsp出现错误can not find the tag directory /web-inf/tags
- 微信小程序出现的Template "icon" not found.的几种原因
- 使用第三方 'Could not find class 'net.htmlparser.jericho.Source' 错误修复 红色感叹号
- Setting property 'source' to 'org.eclipse.jst.jee.server:web' did not find a matching property原因?
- Web启动错误Failed to obtain BeanInfo for class [freemarker.template.Configuration]; nested exception is