<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="templateLoaderPath" value="/WEB-INF/freemarker"/> </bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> <!-- 解決freemarker中文亂碼 --> <property name="contentType" value="text/html;charset=UTF-8"/> <property name="cache" value="true"/> <property name="prefix" value=""/> <property name="suffix" value=".ftl"/> <property name="order" value="0"/> </bean>
加上這個設置編碼格式就好了,最好在頁面也加設置下utf-8