Issue
I'm using pebble template for my Spring MVC application. Is there a way to return JSON response object back instead of HTML template to the client for a particular API call?
When I try to send the JSON object I'm getting the following exception.
com.mitchellbosecke.pebble.error.LoaderException: Could not find template "templates/test/1.html" (?:?)
at com.mitchellbosecke.pebble.loader.ClasspathLoader.getReader(ClasspathLoader.java:74)
at com.mitchellbosecke.pebble.loader.ClasspathLoader.getReader(ClasspathLoader.java:26)
....
....
Caused by
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
Solution
I just needed to add @ResponseBody
in my method and that fixed the issue.
Answered By - DarkCrow
Answer Checked By - Terry (JavaFixing Volunteer)