@Controller
public class ManageEmployee{
@ModelAttribute("employeeForm")
public EmployeeForm createEmployeeForm(Model model, HttpSession session){
EmployeeForm eform = new EmployeeForm ();
List<EmployeeDTO> eList = employeeService.getEmployeeList(employeeId)//employeeId comes from session
eform.setEmployeeDTO(eList );
model.addAttribute("empoyeeList",eList );
return eform;
}
@RequestMapping(value = LogInUris.MANAGE_EMPLOYEE, method = RequestMethod.GET)
public String showEmployee(Model model, ModelMap map) throws ServiceException{
return "employeeView";
}
}
public class EmployeeDTO{
private String eId;
private String eName;
private String eLastName;
private String positon;
private String role;
//getter//setter
}
当用户调用MANAGE_EMPLOYEE
url 然后我返回employeeView
(jsp),我必须在其中显示员工列表,以便用户可以编辑并再次保存它。我知道我可以@JsonSerialize(using=EmployeeDTOSerializer.class)
在我的 DTO 上使用 http 请求Controller
和注释来用户,@ResponseBody
但在这里我将它添加到模型属性中,所以我想知道如何在将对象列表发送到之前将其序列化JSP
。