[JAVA] Spring taglib: form notes

A brief note about Spring jsp form tags

Initial setting(?)

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 %>

Basic shape

The basic form of the form tag is as follows

View page



public class HogeForm {
	private String hoge;
	//Getter and setter omitted


//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
	return "page";


<form:form modelAttribute="checkForm">
    <form:input path="hoge" />
    <input type="submit" />

Receiving the form


public Stiring hogeForm(@ModelAttribute HogeForm form, Model model) {
	//Set to message from the received value
	model.setAttribute("message", form.getHoge());
	return "result";


<!--Omit the basics-->
<!--Display message-->
<p>${ message }</p>

The above is the basic basic form

Description of available tags

form-Create<form> </ form>.

--POST method by default (not specified) --By default (not specified), ╩╗action =" "` specifies the GET that flew in.

╩╗Input`-By default

If you feel like it, continue

Reference site

A brief summary of Spring MVC form tags Spring4 Study Session 1st (2nd)

Recommended Posts

Spring taglib: form notes
Spring Boot Form
Thymeleaf usage notes in Spring Boot
[Introduction to Spring Boot] Form validation check
Spring Framework study notes [Part 1] DI container
Form class validation test with Spring Boot