界面显示是这样
控制台日志打印
[org.springframework.web.servlet.PageNotFound] - No mapping found for HTTP request with URI [/stu/user/{"name":"zhangsan"}] in DispatcherServlet with name 'spring'
代码是:
@Controller
@RequestMapping("/user")
public class UserController {
@RequestMapping(value = "/test", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public String toIndex(HttpServletRequest request,Model model){
return "{\"name\":\"zhangsan\"}";
}
}
整了好久最后在方法加上@ResponseBody注释解决