String par = (String) pars.nextElement();
if (par.startsWith("model.")) {
String fieldName = par.replace("model.", "");
String value = getRequestParameterValue(par);
//这里应该有类型转换和合法性校验
PropertyEditor propertyEditor = new PropertyEditor(fieldName, Operator.eq, value);
Class<?> fieldType = ReflectionUtils.getDeclaredField(model, fieldName).getType();
Object fieldValue;
if (fieldType != propertyEditor.getPropertyType().getValue()) {
LOG.debug(fieldType + "!=" + propertyEditor.getPropertyType().getValue());
fieldValue = propertyEditor.getProperty().getValue().toString();
} else {
fieldValue = propertyEditor.getProperty().getValue();
}
ReflectionUtils.setFieldValue(model, fieldName, fieldValue);
}
}
}