forms work and cleanup
This commit is contained in:
parent
16b56b6de2
commit
8118f458bc
|
@ -28,7 +28,7 @@
|
|||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<version>3.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -24,10 +24,11 @@ public class EmployeeController {
|
|||
if (result.hasErrors()) {
|
||||
return "error";
|
||||
}
|
||||
|
||||
model.addAttribute("name", employee.getName());
|
||||
model.addAttribute("contactNumber", employee.getContactNumber());
|
||||
model.addAttribute("id", employee.getId());
|
||||
return "employeeAdded";
|
||||
return "employeeView";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
package org.baeldung.spring.form;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
public class Employee {
|
||||
|
||||
private String name;
|
||||
private long id;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 1)
|
||||
private String name;
|
||||
@NotNull
|
||||
@Size(min = 1)
|
||||
private String contactNumber;
|
||||
|
||||
public Employee() {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>SpringMVCExample</title>
|
||||
<title>Form Example - Register an Employee</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Welcome, Enter The Employee Details</h3>
|
||||
|
|
Loading…
Reference in New Issue