Answer the question
In order to leave comments, you need to log in
Spring boot: Post request without returning template?
I am using Thymeleaf library
I have a POST function:
@PostMapping("/add2Cart")
void addToCart(@RequestBody String str, HttpServletRequest request) {
...
}
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "add2Cart", template might not exist or might not be accessible by any of the configured Template Resolvers
Answer the question
In order to leave comments, you need to log in
In essence, it is enough to mark the method with the @ResponseBody annotation so that the returned value is treated not as a template name, but as a response:
@PostMapping("/add2Cart")
@ResponseBody
void addToCart(@RequestBody String str, HttpServletRequest request) {
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question