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

    xiaoxiao2021-03-26  30

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

    出现如上问题的解决方案:

    第一,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" />

     

    转载请注明原文地址: https://ju.6miu.com/read-661090.html

    最新回复(0)