forms work and cleanup
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user