Map params = ActionContext.getContext().getParameters();
原来params是以数组的形式存参数值的,修改后的程序段为:
public Object getModel() {
if(userDTO != null) return userDTO;
Integer pid = null;
String sid = null;
Map params = ActionContext.getContext().getParameters();
if(params.get("id")!=null)
{
sid = ((String[])params.get("id"))[0];
}
if(sid!=null&&!sid.equals("")) {
try {
user = userService.getUserByID(new Integer(sid));
//po 转换成 dto
userDTO = new UserDTO(user);
} catch (Exception e) {
log.error("该用户已不存在",e);
}
}else{
userDTO = new UserDTO();
}
return userDTO;
}
原来params是以数组的形式存参数值的,修改后的程序段为:
public Object getModel() {
if(userDTO != null) return userDTO;
Integer pid = null;
String sid = null;
Map params = ActionContext.getContext().getParameters();
if(params.get("id")!=null)
{
sid = ((String[])params.get("id"))[0];
}
if(sid!=null&&!sid.equals("")) {
try {
user = userService.getUserByID(new Integer(sid));
//po 转换成 dto
userDTO = new UserDTO(user);
} catch (Exception e) {
log.error("该用户已不存在",e);
}
}else{
userDTO = new UserDTO();
}
return userDTO;
}