springboot页面调试进入controller,但是页面报404

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_22701869/article/details/81181245

今天调试代码遇到了页面发送请求,controller能够接受,但是页面一直报404,仔细检查过之后,才发现,我在controller使用的是@Controller注解,但是在mapping里面没有使用@responseBody,所以这个时候返回ModelAndView是没有问题的,但是返回json格式的数据就会出错:比如string,map,list等,页面都会报404。

以前写SSM的时候,是没有遇到错误的,在这里遇到这个错,主要是我以为使用的是springboot的@RestController(包含

@Controller,@ResponseBody)注解,所以在RequestMapping中不需要再使用@ResponseBody注解。

注:在写代码的Controller一定要注意@Controller@RestController注解的区别

猜你喜欢

转载自blog.csdn.net/qq_22701869/article/details/81181245