Home > Blockchain >  Is it possible to request the controller without retuning thymleaf model
Is it possible to request the controller without retuning thymleaf model

Time:03-25

Hello I use Thymealf and want to do a validirung against my database before I subbmitte. When I call the controller I get the error:

Error resolving template [], template might not exist or might not be accessible by any of the configured Template Resolvers

I think the error comes from the fact that I don't returne a modal. Is there a way to make a request without thymleaf ?

Controller

@GetMapping("/getByKey/{key}")
public KeyValuePair keyExists(@PathVariable("key") String key){
    return ssdbService.getByKey(key);
}

or do I understand here something completely wrong ?

CodePudding user response:

Use a @RestController instead of a @Controller if you want to return data.

You can also just annotate your method with @ResponseBody if you just want one method to return data instead of the entire controller.

@ResponseBody
@GetMapping("/getByKey/{key}")
public KeyValuePair keyExists(@PathVariable("key") String key){
    return ssdbService.getByKey(key);
}
  • Related