Spring 错误There was an unexpected error (type=Internal Server Error, status=500)解决方法
程序员文章站
2022-03-03 17:23:24
...
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* Created by lixiaofei on 2019/10/18.
*/
@Controller
public class HelloController {
@GetMapping("/hello")
public String hello(@RequestParam(name = "name") String name, Model model){
model.addAttribute("name",name);
return "hello";
}
}
出现错误如下:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sat Oct 19 01:52:14 CST 2019
There was an unexpected error (type=Internal Server Error, status=500).
Circular view path [hello]: would dispatch back to the current handler URL [/hello] again.
Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to
default view name generation.)
解决方案是在@GetMapping下面加上一行@ResponseBody即可。
推荐阅读
-
nginx提示:500 Internal Server Error错误的解决方法
-
thymeleaf There was an unexpected error (type=Internal Server Error, status=500).
-
There was an unexpected error (type=Internal Server Error, status=500). Circular view path [/login]:
-
Spring boot 出现 There was an unexpected error (type=Internal Server Error, status=500)
-
出现There was an unexpected error (type=Internal Server Error, status=500).
-
解决There was an unexpected error (type=Internal Server Error, status=500)问题(使用Thymeleaf报错)
-
There was an unexpected error (type=Internal Server Error, status=500). getWriter() has already been
-
nginx提示:500 Internal Server Error错误的解决方法
-
nginx提示:500 Internal Server Error错误的解决方法
-
nginx提示:500 Internal Server Error错误的解决方法