I use bootstrap and springboot
is used for validation errors, and we want to devise how to display them.
Therefore, I would like to display the bootstrap alerts .

But I can't create a variable that can determine that the errors tag is enabled ...
At first, I tried to enclose the alert part with errors tag, but since it can't nest errors tag, the message prepared in property file cannot be displayed.

Is there an implementation that prepares a variable for determining whether an error has occurred or a message prepared in the property when an error occurs?
Other solutions are also welcome.

Hereafter, write an image when an error occurs.

<% @ page language = "java" contentType = "text/html;charset = UTF-8"%>
<% @ taglib prefix = "form" uri = "http://www.springframework.org/tags/form"%>
   <!-Read js, css->
   <!-I want to branch conditionally when an error message is displayed->
    <strong><form: errors path = "hoge" /></strong>
    <button type = "button" data-dismiss = "alert">
      <span aria-hidden = "true">&times;</span>
  • Answer # 1

    It seems that validation error can be judged with

    spring: bind tag and status.error.
    trueorfalseis set in status.error, andtrueindicates that an error has occurred. >c: if.

    <% @ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
    <% @ taglib prefix = "spring" uri = "http://www.springframework.org/tags"%>

    The status object also hasstatus.valueandstatus.expressionfields, where value is the field value and expression is the field name.

    Once it has been confirmed with Spring Framework 5.1.9.RELEASE.
    The following articles are helpful for this answer. For more details, check out this article.

    Spring MVC Form – Check if a field has an error

    Class BindTag