为什么我不能将任何类型的对象返回给Java中的http请求?为什么我只能返回一个Response对象?这背后的原因是什么?还有其他可能性吗?
如果
List <.employee> employeeList = loyerService.getEmployeeList();
我为什么要这样做:
返回Response.ok(employeeList).build();
而不是:
返回employeeList;
@ Ayushobject serialization之后,可以通过HTTP返回任何对象作为响应。HttpServletResponse对象可用于设置HTTP响应标头(例如,内容类型)和响应消息正文。检查以下链接以获取更多信息:https://www.ntu.edu.sg/home/ehchua/programming/java/JavaServlets.html