admin管理员组文章数量:1612097
控制台输出信息
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Circular view path [adPlace]: would dispatch back to the current handler URL [/adPlace] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)] with root cause
javax.servlet.ServletException: Circular view path [adPlace]: would dispatch back to the current handler URL [/adPlace] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation
解决办法
既把@Controller改成@RestController
@Controller改成@RestController`
1.@RestController注解相当于@ResponseBody + @Controller合在一起的作用。
-
在@controller注解中,返回的是字符串,或者是字符串匹配的模板名称,即直接渲染视图,与html页面配合使用的,
在这种情况下,前后端的配合要求比较高,java后端的代码要结合html的情况进行渲染,使用model对象(或者modelandview)的数据将填充user视图中的相关属性,然后展示到浏览器,这个过程也可以称为渲染 -
而在@restcontroller中,返回的应该是一个对象,即return一个user对象,这时,在没有页面的情况下,也能看到返回的是一个user对象对应的json字符串,而前端的作用是利用返回的json进行解析渲染页面,java后端的代码比较自由。
本文标签: 错误CurrentdispatchSpringBoothandler
版权声明:本文标题:解决Springboot错误--would dispatch back to the current handler URL [XXX] again. Check your ViewResolv 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1728628705a1166828.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论