Skip to content

Commit 8118f45

Browse files
author
eugenp
committed
forms work and cleanup
1 parent 16b56b6 commit 8118f45

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

spring-mvc-xml/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<dependency>
2929
<groupId>javax.servlet</groupId>
3030
<artifactId>javax.servlet-api</artifactId>
31-
<version>3.0.1</version>
31+
<version>3.1.0</version>
3232
<scope>provided</scope>
3333
</dependency>
3434

spring-mvc-xml/src/main/java/org/baeldung/spring/controller/EmployeeController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ public String submit(@Valid @ModelAttribute("employee") final Employee employee,
2424
if (result.hasErrors()) {
2525
return "error";
2626
}
27+
2728
model.addAttribute("name", employee.getName());
2829
model.addAttribute("contactNumber", employee.getContactNumber());
2930
model.addAttribute("id", employee.getId());
30-
return "employeeAdded";
31+
return "employeeView";
3132
}
3233

3334
}

spring-mvc-xml/src/main/java/org/baeldung/spring/form/Employee.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
package org.baeldung.spring.form;
22

3+
import javax.validation.constraints.NotNull;
4+
import javax.validation.constraints.Size;
5+
36
public class Employee {
47

5-
private String name;
68
private long id;
9+
10+
@NotNull
11+
@Size(min = 1)
12+
private String name;
13+
@NotNull
14+
@Size(min = 1)
715
private String contactNumber;
816

917
public Employee() {

spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeHome.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<html>
44
<head>
55
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6-
<title>SpringMVCExample</title>
6+
<title>Form Example - Register an Employee</title>
77
</head>
88
<body>
99
<h3>Welcome, Enter The Employee Details</h3>

spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeAdded.jsp renamed to spring-mvc-xml/src/main/webapp/WEB-INF/view/employeeView.jsp

File renamed without changes.

0 commit comments

Comments
 (0)