简体   繁体   中英

spring el: trouble with parameters

There is a web-service method annotated as @Preautorize

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

And there are two overloaded methods of class implements UserDetails

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

When I call someWebServiceMethod I get somePrincipalMethod(Long longParam, String... stringParams) not somePrincipalMethod(Long longParam1, Long longParam2, String... stringParams)

What do I do wrong?

I have found a solution (workaround).

@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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM