Add the following to the jsp file to use
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form %>
The beginning of the added file is below
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form %>
The basic form of the form tag is as follows
HogeForm.java
//abridgement
public class HogeForm {
private String hoge;
//Getter and setter omitted
}
HogeController.java
//Basic notation is omitted to some extent
public String hogeForm(Model model) {
HogeForm form = new HogeForm();
//Set the initial value you want to display on the form
form.setHoge("foo");
return "page";
}
page.jsp
<form:form modelAttribute="checkForm">
<form:input path="hoge" />
<input type="submit" />
</form:form>
HogeController.java
public Stiring hogeForm(@ModelAttribute HogeForm form, Model model) {
//Set to message from the received value
model.setAttribute("message", form.getHoge());
return "result";
}
result.jsp
<!--Omit the basics-->
<!--Display message-->
<p>${ message }</p>
The above is the basic basic form
form
-Create<form> </ form>
.
--POST method by default (not specified) --By default (not specified), ʻaction =" "` specifies the GET that flew in.
ʻInput`-By default
A brief summary of Spring MVC form tags Spring4 Study Session 1st (2nd)