Click here to Skip to main content
15,066,066 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>  
<!DOCTYPE html>
<html>
<head>

<title>Customer Registration Form</title>

</head>
<style>
	.error {
		color:red;
	}
</style>
<body>
	Fill out the form.Asterisk(*) means required.
	<br><br>
	<form:form action="processForm" modelAttribute="customer">
		First name: <form:input path="firstName"/>
		<br><br>
	
		Last name(*):  <form:input path="lastName"/>
		<form:errors path="lastName" cssClass="error"/>
		
		<br><br>
		Free passes: <form:input path="freePasses" />
		<form:errors path="freePasses" cssClass="error" />
		<br><br>
		<input type="submit" value="Submit" />
	
	</form:form>
</body>
</html>



public class Customer {
	private String firstName;
	
	@NotNull(message="is required")
	@Size(min=1, message="is required")
	private String lastName;
	
	@Min(value=0,message="must be greater than or equal to zero")
	@Max(value=10,message="must be less than or equal to ten")
	private int freePasses;
	
	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public int getFreePasses() {
		return freePasses;
	}

	public void setFreePasses(int freePasses) {
		this.freePasses = freePasses;
	}

	
}


What I have tried:

I have used this code only I have tried many ways but can't see the error messages what to do? I also imported the required libraries and called that and also passed getter and setter too but still cant see errors 
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900