Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add "required" attribute in Spring-MVC [duplicate]

How can I add "required" attribute in Spring-MVC?

I want the ending tag to look like this

<input type="text" name="usrname" required>

So I am doing the following in my JSP

<form:input path="usrname" maxlength="12" required/>

But I am gettng a error

like image 251
SJS Avatar asked Apr 30 '13 17:04

SJS


People also ask

How do you make a field mandatory in Thymeleaf?

The correct way to declare the required attribute in HTML5 with thymeleaf is th:required="required" . Show activity on this post. The Thymeleaf Standard Dialect can process templates in any mode, but is especially suited for web-oriented template modes (XHTML and HTML5 ones).

How does Spring MVC provide validation support?

The Spring MVC framework provides us with standard predefined validators to validate user input data in a simple and straightforward way. The Bean Validation API is the popular approach for data validations in Spring applications.

What is spring form tag?

Spring tag Library The 'form' tag renders an HTML 'form' tag. It exposes a binding path to inner tags for binding the data entered. It puts the command object in the PageContext so that the command object can be accessed by all the inner tags.


1 Answers

I found the fix. my code had to me like this

<form:input path="usrname" maxlength="12" required="required"/>

Now it works.. :)

like image 109
SJS Avatar answered Sep 23 '22 08:09

SJS