I am developing Web Application in Java using Spring Framework. On one page, I am letting user pick year. Here is the code:
@Controller
public class MyController {
@RequestMapping(value = "/pick_year", method = RequestMethod.GET)
public String pickYear(Model model) {
model.addAttribute("yearModel", new YearModel);
return "pick_year";
}
@RequestMapping(value = "/open_close_month_list", method = RequestMethod.POST)
public String processYear(Model model, @ModelAttribute("yearModel") YearModel yearModel) {
int year = yearModel.getYear();
// Processing
}
}
public class YearModel {
private int year;
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
}
This implementation works, but I would like to use something simplier to get year from the user. I think making special model just to get one integer is not very good approach.
So, my question is: Is it possible to somehow simplify this code?
Thank you for any help. Milan