jeecgboot/JeecgBoot · error · JeecgBootException
操作失败,字段名不能为空!
Error message
操作失败,字段名不能为空!
What it means
Thrown by SysTableWhiteListServiceImpl.checkEntity when sysTableWhiteList.getFieldName() is empty or null (checked via oConvertUtils.isEmpty). This JeecgBootException is the third validation in the chain, enforcing that every whitelist entry must specify a field name. It fires after the table-name check passes.
Source
Thrown at jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTableWhiteListServiceImpl.java:68
return true;
}
return false;
}
/**
* 检查需要新增或更新的实体是否符合规范
*
* @param sysTableWhiteList
*/
private void checkEntity(SysTableWhiteList sysTableWhiteList) {
if (sysTableWhiteList == null) {
throw new JeecgBootException("操作失败,实体为空!");
}
if (oConvertUtils.isEmpty(sysTableWhiteList.getTableName())) {
throw new JeecgBootException("操作失败,表名不能为空!");
}
if (oConvertUtils.isEmpty(sysTableWhiteList.getFieldName())) {
throw new JeecgBootException("操作失败,字段名不能为空!");
}
// 将表名和字段名转换成小写
sysTableWhiteList.setTableName(sysTableWhiteList.getTableName().toLowerCase());
sysTableWhiteList.setFieldName(sysTableWhiteList.getFieldName().toLowerCase());
// 如果status为空,则默认启用
if (oConvertUtils.isEmpty(sysTableWhiteList.getStatus())) {
sysTableWhiteList.setStatus(CommonConstant.STATUS_1);
}
}
@Override
public boolean deleteByIds(String ids) {
if (oConvertUtils.isEmpty(ids)) {
return false;
}
List<String> idList = Arrays.asList(ids.split(","));
if (super.removeByIds(idList)) {
// 清空缓存View on GitHub (pinned to 96fb33f5ec)
Solutions
- Add @NotBlank validation annotation on the fieldName field of SysTableWhiteList.
- Ensure the frontend form requires both tableName and fieldName before submission.
- If calling programmatically, set both tableName and fieldName before calling the service.
Example fix
// before
if (oConvertUtils.isEmpty(sysTableWhiteList.getFieldName())) {
throw new JeecgBootException("操作失败,字段名不能为空!");
}
// after — bean validation on the entity
public class SysTableWhiteList {
@NotBlank(message = "表名不能为空")
private String tableName;
@NotBlank(message = "字段名不能为空")
private String fieldName;
// ...
} Defensive patterns
Strategy: validation
Validate before calling
// Validate fieldName is non-empty before calling service
if (sysTableWhiteList == null || oConvertUtils.isEmpty(sysTableWhiteList.getFieldName())) {
return Result.error("操作失败,字段名不能为空");
}
service.save(sysTableWhiteList); Type guard
public boolean hasFieldName(SysTableWhiteList entity) {
return entity != null && oConvertUtils.isNotEmpty(entity.getFieldName());
} Try / catch
try {
service.save(sysTableWhiteList);
} catch (JeecgBootException e) {
if (e.getMessage().contains("字段名不能为空")) {
return Result.error("请填写字段名后重试");
}
throw e;
} Prevention
- Add @NotBlank on the fieldName field with bean validation.
- Require both tableName and fieldName in the frontend form.
- Use @Valid on the controller to reject invalid entities at the boundary.
When it happens
Trigger: Saving or updating a SysTableWhiteList where the fieldName field is null, empty string, or whitespace-only. The table name is provided but the field name is missing.
Common situations: Frontend form submitted with table name but missing field name; API call with incomplete JSON; programmatic caller set tableName but forgot fieldName.
Related errors
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/d49cab7d19b84a8f.
Report an issue: GitHub.