SpelEvaluationException:EL1007E:(pos 43):在null上找不到字段或属性“group” [英] SpelEvaluationException: EL1007E:(pos 43): Field or property 'group' cannot be found on null
问题描述
我为我的Web应用程序完全配置了SPRING METHOD安全性。 (启用PRE / POST注释)。
I have SPRING METHOD security fully configured for my web application. (with PRE/POST annotations enabled).
但是最近我遇到了一个奇怪的问题。总结如下:
However recently I encountered a strange issue with them. Summary as follows:
-
POJOS摘要
Summary of POJOS
// User Class
public class User {
int id;
String name;
// getters and setters
}
// Group Class
public class Group {
int id;
String name;
// getters and setters
}
// GroupMembership class
public class GroupMembership {
private int id;
private User user;
private Group group;
// getters and setters
}
PreAuthorise过滤方法。
PreAuthorise filter on method .
@PreAuthorize("canIEditGroupProfile(#membership.group.id)")
public int updateGroupMembership(GroupMembership membership)
throws GroupsServiceException;
传递完全填充的 GroupMembership
object(存在正确的用户和组合成),安全过滤器抛出以下异常:
Upon passing a fully populated GroupMembership
object (proper user and group compositions present), the security filter throws following exception:
errorMessage: "Failed to evaluate expression
canIEditGroupProfile(#membership.group.id)'"
在深入了解异常时:
原因是:
org.springframework.expression.spel.SpelEvaluationException:
EL1007E:(pos 33): Field or property 'group' cannot be found on null
请提供相同的地址指示。
Please provide pointers to address the same.
推荐答案
getter / setters似乎很好......也没有 null
的情况。
getter/setters seems fine... also no case of null
.
然而这是一个有趣的观察;这个给了我一个错误:
However a interesting observation; this one gives me an error:
@PreAuthorize("canIEditGroupProfile(#membership.group.id)")
public int updateGroupMembership(GroupMembership membership)
throws GroupsServiceException;
这样可行:
@PreAuthorize("canIEditGroupProfile(#groupmembership.group.id)")
public int updateGroupMembership(GroupMembership groupmembership)
throws GroupsServiceException;
我进一步观察到,参数名称在第一次出现时不匹配(即Service和ServiceImpl都有不同参数名称)。
Further I observed, the parameter name was mismatching in case of first (i.e Service and ServiceImpl both had different parameter names).
现在保持一致性,问题似乎是固定的。
Now maintaining the uniformity, the issue seems to be fixed.
这篇关于SpelEvaluationException:EL1007E:(pos 43):在null上找不到字段或属性“group”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!