admin管理员组

文章数量:1612098

控制台输出信息

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合在一起的作用。

  1. 在@controller注解中,返回的是字符串,或者是字符串匹配的模板名称,即直接渲染视图,与html页面配合使用的,
    在这种情况下,前后端的配合要求比较高,java后端的代码要结合html的情况进行渲染,使用model对象(或者modelandview)的数据将填充user视图中的相关属性,然后展示到浏览器,这个过程也可以称为渲染

  2. 而在@restcontroller中,返回的应该是一个对象,即return一个user对象,这时,在没有页面的情况下,也能看到返回的是一个user对象对应的json字符串,而前端的作用是利用返回的json进行解析渲染页面,java后端的代码比较自由。

本文标签: 错误CurrentdispatchSpringBoothandler