forms work and cleanup

This commit is contained in:
eugenp 2014-08-11 23:17:24 +03:00
parent 16b56b6de2
commit 8118f458bc
5 changed files with 13 additions and 4 deletions

View File

@ -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>

View File

@ -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";
} }
} }

View File

@ -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() {

View File

@ -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>