[Java] Java diary

less than 1 minute read

⭕️Spring⭕️ A little summary of what I learned today!

Form tag that is often found in JSP(view)! What is the modelAttribute in the first line? .. ..

1<form:form modelAttribute="□□□">
3<p><form:input path="id" /></p>
4<p><form:input path="name" /></p>
6<input type="submit" value="register" />

In the □□□ part, specify the Model name (the one with many setters and getters) that has the id and name sent in the 3rd and 4th lines! (It seems that the initials are lower case)

Q: If the initials were changed to lowercase, it would be different from the Model name, wouldn’t it?

A: For example, if the above Model name is MemberModel, In the doGET method of Controller

model.addAttribute("memberModel",new MemberModel());

And described. (I can’t explain it well, but it seems like it needs it because he has the id and name that he wants to use…)

Because I use the memberModel of this first argument

The value of modelAttribute of form tag has the same name as Model, but the initial letters are lowercase!

If you wrote something wrong, I’d be happy to let you know.