您的位置:首页 > 编程语言 > Java开发

javax.servlet.ServletException: Could not resolve view with name 'xxxxx'in servlet with name 'xxx'

2017-12-18 10:33 405 查看
在请求的返回值中加入 @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" />
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐