spring boot 返回json There was an unexpected error (type=Not Found, status=404).

匿名 (未验证) 提交于 2019-12-02 23:03:14

在做一个spring boot的小demo的时候,完全是按照其他人的例子来做的,但是运行以后返回界面始终是404:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Apr 17 13:12:15 CST 2018
There was an unexpected error (type=Not Found, status=404).
No message available
页面上也不明说错了什么,查了很多地方都说是Application类的位置应该放在最外面的包中,一小部分提示缺少依赖,但都没有解决这个问题。

最好发现是controller类的的一个注解写错了。

原来:

@Controller
@RequestMapping("/user")
public class LoginController {



现在:

@RestController
@RequestMapping("/user")
public class LoginController {



就是把@Controller改为@RestController就可以了




版权声明:本文为博主原创文章,转载请附上博文链接!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!