springlaravel

What is similar function of dd() from Laravel in Spring?


I recently change to Spring-boot for development. Can anyone help me to understand better in Spring?

In laravel, there is dd() function, which is useful to dump variable value. The picture below show the result of dd(). Can I achieve same thing in Spring?

Result of 'dd()'


Solution

  • There is no such behavior, but you can make it similar.

    1. Create an exception and include the result data you want to see.
    2. Register the exception in the @ExceptionHandler.
    3. If you want to be global, create an @ExceptionHandler in @ControllerAdvice.