Spring:Can we create custom HTTP Status codes ?

Can we create custom HTTP Status codes ?

阅读 2.7k
1 个回答

Ofcourse, you can use raw servlet api HttpServletResponse,

@RequestMapping("test")
public void test(HttpServletResponse response) throws IOException {
    response.setStatus(10000); // http status code 10000(NOT EXISTS)
    response.flushBuffer();
}

But is's not recommend to use a HTTP status code that does not exists,
cause the clients don't know what it means

clipboard.png

推荐问题