0
Follow
2
View

Encoding problem when sending a request using RestTemplate

yao2306 注册会员
2023-01-26 02:55

With this:

MediaType mediaType = new MediaType("text", "html", utf8);
headers.setContentType(mediaType);

You're telling Spring that the content of your payload will be text/html.

However, with this:

var httpEntity = new HttpEntity<>(emailDto , headers);

You're telling Spring to send an EmailDto object - which understandably Spring has no idea how to convert to text/html and Spring won't know that EmailDto happens to contain a field with HTML in it.

About the Author

Question Info

Publish Time
2023-01-26 02:55
Update Time
2023-01-26 02:55