String firstCharUpper = roadSpectrumConfigInfo1.getParamName().substring(0, 1).toUpperCase(); String invokeMethodName = "get" + firstCharUpper + roadSpectrumConfigInfo1.getParamName().substring(1); Method pendingInvokeMethod = roadSpectrumFormInfo.getClass().getMethod(invokeMethodName); Object invokeResult = pendingInvokeMethod.invoke(roadSpectrumFormInfo); if(invokeResult == null || "".equals(invokeResult)){ message=message+"请填写"+roadSpectrumConfigInfo1.getParamRemark()+"信息;"; }
反射判定该类的某个属性值是否为空
![](https://img-home.csdnimg.cn/images/20240711042549.png)