Is there a way to pass a String value from my Spring controller class to my HTML? In various "hello world" examples, they say to use
ModelAndView model = new ModelAndView("htmlPageName");
model.addAttribute("variableName", "someValue");
in the controller and
${variableName}
in the HTML. But when I load the page it shows literally ${variableName}
instead of "someValue"
Am I missing something?
This is a very basic Web Application using Spring Boot that serves a “Hello World” static HTML web page. This will start the embedded Tomcat server at port 8080. The web server is available out of the box with Spring Boot.
If you use Thymeleaf
<h1 th:text="${variableName}"></h1>
You wrote: {$variableName} instead of ${variableName}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With