JAVA-2107: Moved code for 1 article to spring-thymeleaf-3
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package com.baeldung.thymeleaf.option;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* Simple student POJO with few fields
|
||||
*
|
||||
*/
|
||||
public class Student implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8582553475226281591L;
|
||||
|
||||
@NotNull(message = "Student ID is required.")
|
||||
@Min(value = 1000, message = "Student ID must be at least 4 digits.")
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "Student name is required.")
|
||||
private String name;
|
||||
|
||||
@NotNull(message = "Student gender is required.")
|
||||
private Character gender;
|
||||
|
||||
private Float percentage;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Character getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(Character gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public Float getPercentage() {
|
||||
return percentage;
|
||||
}
|
||||
|
||||
public void setPercentage(Float percentage) {
|
||||
this.percentage = percentage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.baeldung.thymeleaf.option;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
|
||||
/**
|
||||
* Handles requests for the student model.
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class StudentController {
|
||||
|
||||
|
||||
@RequestMapping(value = "/student", method = RequestMethod.GET)
|
||||
public String addStudent(Model model) {
|
||||
model.addAttribute("student", new Student());
|
||||
return "option/studentForm.html";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user