Render a view with thymeleaf and a custom content-type

Viewed 104

I intend to some frontend technique that requires a custom content-type as response to a controller post.

I want to use thymleaf to produce my response like I do for my normal webpages. I know how to normally change the content type in the spring-mvc eco-system. But it seems that thymleaf is forcing another content-type on my behalf.

Here is the code

@PostMapping(path="/messages", produces = {"text/vnd.turbo-stream.html"})
  public String messages(ModelMap model) {
    return "messages";
  }

I've found this: https://github.com/brunodrugowick/hotwire-springboot-thymeleaf-sample/blob/master/src/main/java/dev/drugowick/hotwirespringbootthymeleafsample/config/ThymeleafConfig.java

But I'd rather select my content-type by hand. Is there a way?

0 Answers
Related