SpingMVC集成FreeMark的问题

问题:

No qualifying bean of type [org.springframework.web.servlet.view.freemarker.FreeMarkerConfig] is def

 

需要在在springmvc.xml中配置:

 

 <!-- 自动扫描且只扫描@Controller -->

<context:component-scan base-package="com.qtoon.property.house.controller"></context:component-scan>

 

 <!-- FreeMarker配置 -->

<bean id="freeMarkerConfigurer" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
		<property name="templateLoaderPath" value="/WEB-INF/views" /> <!--模板放置的路径 -->
		<property name="defaultEncoding" value="UTF-8" />
		<property name="freemarkerSettings">
			<props>
				<prop key="tag_syntax">auto_detect</prop>
				<prop key="template_update_delay">0</prop>
				<prop key="defaultEncoding">UTF-8</prop>
				<prop key="output_encoding">UTF-8</prop>  
				<prop key="url_escaping_charset">UTF-8</prop>
				<prop key="locale">zh_CN</prop>
				<prop key="boolean_format">true,false</prop>
				<prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
				<prop key="date_format">yyyy-MM-dd</prop>
				<prop key="time_format">HH:mm:ss</prop>
				<prop key="number_format">0.######</prop>
				<prop key="whitespace_stripping">true</prop>
				<prop key="classic_compatible">true</prop>
				<!-- <prop key="auto_import">/ftl/spring.ftl as s</prop>  --><!--自动引入的文件 -->
				<prop key="template_exception_handler">ignore</prop>
			</props>
		</property>
	</bean>

 

 

 

 

	<!-- 定义Freemarker -->
	<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
 		<property name="cache" value="false" /><!-- 开发期间改为false,生产环境设置为true -->
		<property name="contentType" value="text/html;charset=UTF-8"/>
		<property name="prefix" value="/user/" /> <!-- ftl文件访问的路径  也可指定"/" -->
		<property name="suffix" value=".ftl" />
		<property name="exposeSpringMacroHelpers" value="true" />
		<!-- 允许访问请求属性,默认为false -->
		<property name="exposeRequestAttributes" value="true" />
		<!-- 允许访问会话属性,默认为false -->
		<property name="exposeSessionAttributes" value="true" />
		<!-- 页面上下文,类似于request.contextPath -->
		<property name="requestContextAttribute" value="rc" />
 	</bean>

 

HouseController

package com.qtoon.property.house.controller;


import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@Scope(value="prototype")
@RequestMapping("/bill")
public class HouseController {

	@RequestMapping("/import")
	public ModelAndView checkBill() {
		
		ModelAndView view = new ModelAndView("house");
		return view;
	}
}

 

资源访问路径请看附件图片:

例图

 

 

你可能感兴趣的:(freemark)