0

jboss EAP + 弹簧架控制器

我的问题是错误响应,即使我抛出异常,错误消息客户端从 jboss 接收 html 错误页面。没有我的错误消息。所以我的代码无法解析错误,结果我必须显示一般错误消息。

以下是我的休息控制器实现

@RequestMapping(value = "/save", method = RequestMethod.POST, produces = "application/json")
public ResponseEntity<PModel> saveProgram(Authentication authentication, @RequestBody PModel p){


    m = pService.saveP(p, authentication.getName());
    return new ResponseEntity<PModel>(m, HttpStatus.OK);
}

我的 pService.save 引发如下错误

Save(){
…
throw new RuntimeException("ID not found: "+model.id);
}

我的角度发布请求如下

getP
(p: P):Observable<P>{

    return this.http.post('api/program/types', p, this.prepareHeaderInfo()) // ...using post request
        .map((res:Response) => res.json() as P) // ...and calling .json() on the response to return data
        .catch((error:any) => Observable.throw(error.json().error || 'Server error')); //...errors if

}

我收到的响应为 html 的错误,如下所示,没有我的错误

<html><head><title>JBoss Web/-redhat-1 - JBWEB000064: Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>JBWEB000065: HTTP Status 400 - </h1><HR size="1" noshade="noshade"><p><b>JBWE: type</b> JBWE: Status report</p><p><b>JBWE: message</b> <u></u></p><p><b>JBWE: description</b> <u>JBWE: The request sent by the client was syntactically incorrect.</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.5.7.Final-redhat-1</h3></body></html>
4

0 回答 0