0
사용자 지정 JSON 오류 메시지를 렌더링하고 싶습니다. 나는 다음과 같은 한 UrlMappings
클래스 내부컨트롤러의 Grails 오류 처리
class ErrorController {
static responseFormats = ['json']
def notAuthorized() {
render([error: "You are not authorized to access ${request.getRequestURL()} on this server.",
path: request.getRequestURI()] as JSON)
}
}
:
{"error":"You are not authorized to access http://localhost:8080/error on this server.",
"path":"/error"}
:
"401"(controller: 'error', action: 'notAuthorized')
모든 나는 다음과 같은 오류 메시지가 GET http://localhost/path
는 사실을 제외하고 확실히 작동 나는 다음과 같은 컨트롤러를 생성
request
개체의 URI/URL이 요청에 지정된 URI/URL을 가리 키지 않습니다. 올바른 URI/URL을 얻을 수있는 방법이 있습니까?