I'm new to Spring and this is my question. I want to access a created list everytime a specific route is called. The list is created by a csv file, and I want to create the list only once. (I know hot to create a list from csv). I don't understand when and if the cunstructor of the controller is called, and I don't know if everytime the route is called, it uses another instance of the controller?
@Controller
public class Controller {
List<List<String>> csvAsList; // how to initialize this list?
public Controller(List<List<String>> csvAsList) {
this.csvAsList = csvAsList;
}
@RequestMapping(value = "home/{userTypedRoute}")
@ResponseBody
public String printRoute(@PathVariable String userTypedRoute){
//access the list
return userTypedRoute;
}
}