需要配置一下:
springboot中配置
## Freemarker \u914D\u7F6E
## \u6587\u4EF6\u914D\u7F6E\u8DEF\u5F84
#spring.velocity.resource-loader-path=classpath:/templates/
spring.freemarker.cache=false
spring.freemarker.charset=UTF-
spring.freemarker.check-template-location=true
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=true
spring.freemarker.expose-session-attributes=true
spring.freemarker.request-context-attribute=request
# \u89C6\u56FE\u540D\u540E\u7F00
spring.freemarker.suffix=.ftl
spring中配置
<!-- FreeMarker视图解析 如返回userinfo。。在这里配置后缀名ftl和视图解析器。。 -->
<bean id="viewResolverFtl"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
<property name="suffix" value=".ftl" />
<property name="contentType" value="text/html;charset=UTF-8" />
<property name="exposeRequestAttributes" value="true" />
<property name="exposeSessionAttributes" value="true" />
<property name="exposeSpringMacroHelpers" value="true" />
<property name="requestContextAttribute" value="request" />
<property name="cache" value="true" />
<property name="order" value="" />
</bean>