Basically I have a Form which I have an Object 'Sighting' being made, when being requesting the specific URL to make a sighting. Although, In the form I have another object Which I would like in a tag to be populated from a database. This select tag basically gets all the 'pests' from a database and populates them. My controller is setting adding 2 attributes like this, I am not sure if it is the correct way of doing it, or will one object overwrite another when submitting it.
My Controller Method:
@RequestMapping("/sighting")
public String makeSighting(Model model, Principal principal) {
List<Pest> pests = pestsService.getPests();
model.addAttribute("pests", pests);
model.addAttribute("sighting", new Sighting());
return "sighting";
}
If you could help me out that would be great. If needed I will provide the code for the Form also. Thanks