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