spring el:参数问题

时间:2017-09-19 07:31:35

标签: java spring-el

有一个注释为@Preautorize

的Web服务方法
@PreAuthorize("principal.somePrincipalMethod(#request.property1, #request.property2, 'stringA', 'stringB')")
public SomeResponse someWebServiceMethod(SomeRequest request) {
...
}
public class SomeRequest {
    Long property1;
    Long property2;
}

并且有两个重载方法的类实现UserDetails

public boolean somePrincipalMethod(Long longParam1, Long longParam2, String... stringParams) {
    return true;
}
public boolean somePrincipalMethod(Long longParam, String... stringParams) {
    return true;
}

当我致电someWebServiceMethod时,我somePrincipalMethod(Long longParam, String... stringParams)而不是somePrincipalMethod(Long longParam1, Long longParam2, String... stringParams)

我做错了什么?

1 个答案:

答案 0 :(得分:0)

我找到了解决方案(解决方法)。

@PreAuthorize("principal.somePrincipalMethod(#request.property1, #request.property2, {'stringA', 'stringB'})")
public SomeResponse someWebServiceMethod(SomeRequest request) {
...
}
public boolean somePrincipalMethod(Long longParam1, Long longParam2, String[] stringParams) {
    return true;
}
public boolean somePrincipalMethod(Long longParam, String[] stringParams) {
    return true;
}