在请求的返回值中加入 @ResponseBody
如果还是没有
则需要对springMvc 配置文件进行配置
第一,springmvc的配置文件中
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/templates/" />
<property name="defaultEncoding" value="utf-8" />
模版加载地址配置是否正确 value="/templates/"
在controller中返回的页面地址需去掉默认加载路径 ( templates/login.ftl) 需去掉 templates
第二,返回json格式的数据的时候需注意 在配置文件中配置的
<property name="defaultContentType" value="text/html" />改为<property name="defaultContentType" value="application/json" />