作者:antefigure850_495 | 来源:互联网 | 2023-06-06 17:31
先上代码:123456789@Controller@RequestMapping(value = "/hello")public class HelloController { @Request
先上代码:
1 2 3 4 5 6 7 8 9
| @Controller
@RequestMapping(value = "/hello")
public class HelloController {
@RequestMapping("/user/{id}.json")
public void reponseModel(HttpServletRequest request, @PathVariable long id, Model model){
model.addAttribute("xm",xiaoming);
model.addAttribute("xh",123);
}
} |
然后访问:http://127.0.0.1:8080/hello/u... 就能得到{"xm":xiaoming,"xh":123} ???
感觉很新鲜,自己写了代码试了试,发现并没有返回json数据,什么都没有返回!有没有知道这种返回json的方式,是不是还有哪些地方我没有注意。