H5W3
当前位置:H5W3 > java > 正文

【Java】关于FreeMarkerViewResolver的配置

<bean class=”org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer”>

    <property name="templateLoaderpaths" value="/WebContent/jsp/"></property>
<property name="defaultEncoding" value="utf-8"></property>
<property name="freemarkerSettings">
<props>
<prop key="locale">zh_CN</prop>
</props>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="suffix" value=".*"></property>
<property name="contentType" value="text/html;charset=utf-8"></property>
<property name="requestContextAttributes" value="request" />
<property name="exposeRequestAttributes" value="true" />
<property name="exposeSessionAttributes" value="true" />
</bean>

org.springframework.beans.NotWritablePropertyException: Invalid property ‘templateLoaderpaths’ of bean class [org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer]: Bean property ‘templateLoaderpaths’ is not writable or has an invalid setter method. Did you mean ‘templateLoaderPath’, or ‘templateLoaderPaths’?

at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1064)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:924)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
... 31 more

回答

templateLoaderpaths这个bean的名称不对,改成这个试试templateLoaderPaths

谢谢大家,我已找到原因了。

本文地址:H5W3 » 【Java】关于FreeMarkerViewResolver的配置

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址