I have a form like this:
<form action="/list/${tableName}" method="post">
<p>
<select name="tableName">
<option value="employees">Employees</option>
<option value="contracts">Contracts</option>
</select>
</p>
<input type="submit" value="Submit" />
</form>
and on the controller side:
@RequestMapping(value = "/list/{tableName}", method = { RequestMethod.POST, RequestMethod.GET })
public String getTables(Model m, @PathVariable("tableName") String tableName) {
...
//findAll here
...
return "home";
}
It writes "not found" P.S.: what is now @PathVariable used to be @RequestParam as I'm using it in the body as well. How do I pass the options as a variable to the controller so that I get list/employees and list/contracts when I list the table data with findAll?
`@RequestMapping(value = "/list/{tableName}", method = { RequestMethod.POST, RequestMethod.GET }) public String getTables(Model m, @PathVariable("tableName") String tableName) { Integer idPrepend = spravochnikService.getIdAtSpravName(tableName); List spravList = spravochnikService.findAll(tableName);
m.addAttribute("spravList", spravList);
m.addAttribute("tableName", tableName);
m.addAttribute("idPrepend", idPrepend);
return "home";
}`
` – Nikrango Apr 24 '19 at 09:16