I want to host JSON file from project directory, i put a file in src/main/resources/templates/movies1.json. The @GetMapping is shown below.
package com.rameelhashmi.springboot.movies.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class MoviesController {
// create a mapping for "/hello"
@GetMapping("/movies1")
public String MoviesJson() {
return "movies1";
}
@GetMapping("/movies")
public String Movies1() {
return "movies";
}
}
In my HTML code i give the link for JSON file is: $.getJSON("http://localhost:8080/movies1", function(data){
The HTML page does not load the JSON file from directory, But if i change the movies1.json to movies1.html it works perfectly fine. The error in console shows as:
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [movies1], template might not exist or might not be accessible by any of the configured Template Resolvers