根据字段名动态获取属性值
/**
* 根据字段名动态获取属性值
**/
public String getValByJavaName(String javaName,Object obj){
String firstLetter = javaName.substring(0, 1).toUpperCase();
String getMethodName = "get" + firstLetter + javaName.substring(1);
String val = null;
try {
Method m = obj.getClass().getMethod(getMethodName);
val = (String) m.invoke(obj,null);
} catch (Exception e) {
e.printStackTrace();
}
return val;
}