先看代码:
@RestController
public class SampleController {
@RequestMapping("/resp")
public String sampleResp(){
System.out.println(1/0);
return "Hello";
}
}
此时使用postman或者httprequester请求,响应状态码500,但是response中如下:
{
"timestamp": 1489320286710,
"status": 500,
"error": "Internal Server Error",
"exception": "java.lang.ArithmeticException",
"message": "/ by zero",
"path": "/resp"
}
第一个问题:
目前项目中没有做统一异常处理和添加ExceptionnReslovers, 有没有能帮忙找出具体源码,就是这些信息从哪里取出来的。
第二个问题:
ResponseEntity中存在于HttpStatus和HttpHeader,可以通过ResponseEntity来返回Http的头和状态, 我想知道源码中具体的response.setStatus和addHeader在哪里?
刚刚使用CSDN,没多少金币,求大神帮忙。