首页 > 代码库 > SPRINGMVC+FREEMARKER 配置问题

SPRINGMVC+FREEMARKER 配置问题

【原配置】

<dispatch-servlet.xml>  DispatcherServlet 对应的配置文件 

<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
  <property name="viewClass"  value="http://www.mamicode.com/org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
  <property name="contentType" value="http://www.mamicode.com/text/html;charset=UTF-8" />
  <property name="prefix" value="http://www.mamicode.com/WEB-INF/ftl/" />
  <property name="suffix" value="http://www.mamicode.com/.html" />
 </bean>
 
 <bean id="freemarkerConfig"  
      class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">  
    
    <property name="templateLoaderPath" value="http://www.mamicode.com/WEB-INF/view/" />  
    <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">ignore</prop>  
        </props>  
    </property>  
</bean> 

【出现问题】

  Could not resolve view with name ‘/XXXX‘ in servlet with name ‘spring‘

 【解决方法】

  freemarkerConfig 中配置了templateLoaderPath 就不需要viewResolver中的prefix

SPRINGMVC+FREEMARKER 配置问题