我的jsp中有简单的表格。
<table class="table table-bordered">
<tr>
<th>#</th>
<th>Name</th>
<th>Surname</th>
<th>Age</th>
<th>Email</th>
</tr>
<c:forEach var="employee" items="${employeeList}">
<tr class=row>
<td>${employee.id}</td>
<td>${employee.name}</td>
<td>${employee.surname}</td>
<td>${employee.age}</td>
<td>${employee.email}</td>
</tr>
</c:forEach>
</table>
我的控制器:
@Controller
public class BrowseController {
@Autowired
private SpringJdbcDao springJdbcDao;
public void setSpringJdbcDao(SpringJdbcDao springJdbcDao) {
this.springJdbcDao = springJdbcDao;
}
@RequestMapping(value = "/browse")
public String browseEmployees(Model model) {
List<Employee> employeeList = new ArrayList<Employee>(springJdbcDao.getEmployeesList());
model.addAttribute("employeeList", employeeList);
return "browse";
}
@RequestMapping(value = "/browse/details/{id}", method = RequestMethod.GET)
public String viewDetails(@PathVariable("id") int id, Model model) {
Employee employee = springJdbcDao.getEmployeeById(id);
model.addAttribute("data", employee);
return "details";
}
}
我需要通过单击表格的行重定向到“/browse/details/{id}”以查看有关员工的详细信息。我怎样才能做到这一点?