suchen

Heim  >  Fragen und Antworten  >  Hauptteil

java - Spring:Can we create custom HTTP Status codes ?

Can we create custom HTTP Status codes ?

怪我咯怪我咯2848 Tage vor732

Antworte allen(1)Ich werde antworten

  • 黄舟

    黄舟2017-04-18 10:36:24

    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

    Antwort
    0
  • StornierenAntwort