Ich möchte eine Bibliothek erstellen, die den Json Inhalt der Anfrage und Antwort auf annotierten Spring Controller speichern wird.Get json Inhalt der Anfrage und Antwort auf annotierten Spring Controller
Also habe ich meine eigene Anmerkung @foo bauen und sie auf einigen Controllern setzen:
@Foo
@RequestMapping(method = RequestMethod.POST, value = "/doSomeThing", produces = {
MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE,
MediaType.APPLICATION_XML_VALUE})
public ResponseEntity<T> doSomething(/*some parameters*/) {
T t = doSomeJob(T.class);
return new ResponseEntity<T>(t, HttpStatus.OK);
}
Ich habe keine Garantie dafür, dass und Antwort verlangen, sind in Contrellor-Parameter! Und ich fange den Anruf auf jedem Controller mit dieser Annotation innerhalb eines @AfterReturning AOP Pointcut.
@Component
@Aspect
public class XYInterceptor
@AfterReturning(
pointcut = "execution(@my.annotation.Foo)")
public void doSomethingWithJsonContent(JoinPoint joinPoint) throws Throwable {
//How can i get json value of request and response here?
}
Wie kann ich Anfrage- und Antwort Inhalt in json formatiert (wie es ist senden/an den Client zurückgegeben)?
Danke für Ihre Hilfe!