I am unable to load the input and instance values in the browser from the HTML file using Thymeleaf for a Spring-boot application.
Below is code snippet from Controller java file.
@RequestMapping(value = "/x")
public String launch(@RequestParam("inputFile") String inputFile, @RequestParam("instance") int instance) {
...
ModelAndView mav = new ModelAndView();
Map<String, String> parameters = new HashMap<>();
parameters.put("inputFile", inputFile);
parameters.put("instance", Integer.toString(instance));
mav.addObject("parameters", parameters);
mav.setViewName("welcome");
return "welcome";
}
Here is the code from welcome.html:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div class="container">
<div class="starter-template">
<h1>Success!</h1>
<h2><span th:text="inputFile: ${parameters.inputFile}"></span></h2>
<h3><span th:text="instance: ${parameters.instance}"></span></h3>
</div>
</div>
</body>
</html>
Here is the error I get on the browser:
Could not parse as expression: "inputFile: ${parameters.inputFile}" (welcome:16)