---
title: "Discussion on \"Handle SpringBoot ResponseBodyAdvice Error: xxx cannot be cast to java.lang.String\" | Hashnode"
description: "Discussion on \"Handle SpringBoot ResponseBodyAdvice Error: xxx cannot be cast to java.lang.String\". I encountered an error when trying to use the ResponseBodyAdvice interface to customize the response after executing the controller method with @ResponseBody annotation. The issue occurred when a controller method was returning a String, resulting in..."
url: "https://hashnode.com/posts/handle-springboot-responsebodyadvice-error-xxx-cannot-be-cast-to-java-lang-string-e64fad76d56e/649fc4c840dce52282133df5"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Handle SpringBoot ResponseBodyAdvice Error: xxx cannot be cast to java.lang.String](https://backend-with-java.hashnode.dev/handle-springboot-responsebodyadvice-error-xxx-cannot-be-cast-to-java-lang-string-e64fad76d56e?utm_source=hashnode&utm_medium=feed)

I encountered an error when trying to use the ResponseBodyAdvice interface to customize the response after executing the controller method with @ResponseBody annotation. The issue occurred when a controller method was returning a String, resulting in...

Jul 1, 2023 · 4 min read · backend-with-java.hashnode.dev  
Read the article

-   [#programming-blogs](https://hashnode.com/tag/programming-blogs)
-   [#java](https://hashnode.com/tag/java)
-   [#springboot](https://hashnode.com/tag/springboot)
-   [#dispatcherservlet](https://hashnode.com/tag/dispatcherservlet)
-   [#responsebodyadvice](https://hashnode.com/tag/responsebodyadvice)

## Written by

[Li Qi](https://hashnode.com/@CharlesLi)

@CharlesLi · Shanghai, China

  
[View profile](https://hashnode.com/@CharlesLi)

Java Backend Developer

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
