garden lee
garden lee

Reputation: 31

Why model.addAttribute and ${} is not matching and it shows just . on web?

I just started to learn jsp and spring. I deleted formattedDate (as a default) in HomeController.java and changed to model.addAttribute("answer", "yes") and on web, it only shows . and i don't understand why. I tried to put definition like String answer = "yes" but it didnt work.

this is HoneController.java:

    @Controller
    public class HomeController {
        @RequestMapping("/main")
        public String home(Locale locale, Model model) {
            model.addAttribute("answer", "yes");

            return "home";
        }
    }

and here is home.jsp:

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ page session="false" pageEncoding="UTF-8" %>
    <html>
    <head>
        <title>Home Page</title>
    </head>
    <body>
    <h1>
        hello
    </h1>
    <P> Is it happening? : ${answer}. </P>
    </body>
    </html>

There was no error messages this is the result.

Upvotes: 0

Views: 55

Answers (0)

Related Questions