1

I'm returning value from my controller. Let it be ResponseEntity<String> type.

Controller returns:

new ResponseEntity<String>("{\"msg\":\"success\"}",HttpStatus.OK); 

Following value goes to my spring aspect. I am receiving this object in following code:

@AfterReturning(pointcut = "somePointcut()",returning = "retVal") public ResponseEntity<String> adviceTest3(Object retVal) { //here i have access to controller's object return new ResponseEntity<String>("{\"msg\":\"changed value within aspect\"}",HttpStatus.OK); } 

I'm aware that there is @AfterReturning. Is it any way manipulate data and achieve that?

1 Answer 1

1

With @AfterReturning, no. Quote from the documentation

An after returning advice has access to the return value (which it cannot modify), invoked method, methods arguments and target.

You could use @Around instead.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.