spring-el

Passing varargs to Spring spEL causes “Method cannot be found on com.sun.proxy”

回眸只為那壹抹淺笑 提交于 2019-12-02 06:25:59
I try to write custom class for permissions evaluation, so it can be used with Spring Security @PreAuthorize and Spring Expression Language like for example this ( authority is just a regular Spring component with some role names): @PreAuthorize("@permissionEvaluator.anyOfRoles(@authority.ADMIN)") The PermissionEvaluator#anyOfRoles method declaration looks like follows: boolean anyOfRoles(String... roles) As shown this method takes varargs of String type. It works fine when only one parameter is passed (as on the example above) but calling it with more than one argument, eg. @PreAuthorize("

SpEL in @Qualifier refer to same bean

独自空忆成欢 提交于 2019-12-02 03:36:24
I am interested to inject a bean reference, which is resolved based on another property on the same bean: @Autowired @Qualifier("#{'prefix' + actualQualifier}") private OtherBean otherBean private String actualQualifier; This would ensure that the relationship between "actualQualifier" and "otherBean" is correct. There is a number of beans configured of the type OtherBean . I can make sure that "actualQualifier" has a value set before autowiring/injection begins. I am unable to find any way to reference another property value (in the JavaBean sense) on the same bean that is currently being

Using spring3 @Value to access PropertyPlaceholderConfigurer values?

时光总嘲笑我的痴心妄想 提交于 2019-12-01 16:15:10
I'm trying to set the value of a string in a spring bean using @Value , when my property source is a subclass of PropertyPlaceholderConfigurer . Anyone know how to do this ? micfra Old question, but still worth to be answered. You can use the expression the same way as you would with the original PropertyPlaceholderConfigurer . app.properties app.value=Injected app-context.xml <bean id="propertyConfigurer" class="MyPropertyPlaceholderConfigurer"> <property name="location"> <value>file:app.properties</value> </property> </bean> in the target bean @Value(value="${app.value}") private String

How do I escape values in SpEL?

断了今生、忘了曾经 提交于 2019-12-01 15:32:36
I am writing some SpEL statements in XML, and I can't get the parser to determine when I need to escape a character. I've attempted the following: <... property="someProperty" value="#{ someBean.aMethodOnTheBean('st\'ring') }" /> However adding in the \' does not seem to escape that single quote and I keep receiving a parser exception. Is there any way to escape these values? Damon From the documentation : "To put a single quote itself in a string use two single quote characters." expression = 'something = ''' + someMethod.getValue + '''' I modified to: .... value="#{ someBean.aMethodOnTheBean

Using spring3 @Value to access PropertyPlaceholderConfigurer values?

别等时光非礼了梦想. 提交于 2019-12-01 15:12:27
问题 I'm trying to set the value of a string in a spring bean using @Value , when my property source is a subclass of PropertyPlaceholderConfigurer . Anyone know how to do this ? 回答1: Old question, but still worth to be answered. You can use the expression the same way as you would with the original PropertyPlaceholderConfigurer . app.properties app.value=Injected app-context.xml <bean id="propertyConfigurer" class="MyPropertyPlaceholderConfigurer"> <property name="location"> <value>file:app

SpelEvaluationException Method cannot be found

青春壹個敷衍的年華 提交于 2019-12-01 13:23:23
I am facing with the next problem, when I am trying to pass the User to the service method using SpEL, evaluate expression="commonService.userTest(user)" result="flowScope.user" spring throws me the following exception: org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 14): Method call: Method userTest(com.x.domain.common.User) cannot be found on com.sun.proxy.$Proxy114 type But when I am passing a plain text instead of the User object, evaluate expression="commonService.userTest('Hello')" result="flowScope.user" There are no errors. @Entity @Table(name = "users")

Thymeleaf compare #locale expression object with string

我们两清 提交于 2019-12-01 11:27:47
I want to set a th:class attribute depending on the context locale using the expression object #locale. I have tried th:class="${#locale}=='en'?'active':''" th:class="${#locale=='en'}?'active':''" Both of them results in false, but whent I print it with th:text="${#locale}, I got the correct locale code (en,es). Any idea of how to compare the #locale object with a locale code? Armando Pérez Based on the answer posted by David_Garcia , I could resolve my issue this way: th:class="__${#locale}__=='en'?'active':'' This is a issue that I told to the guys of thymeleaf time ago. You need to resolve

Spring @Cacheable with SpEL key: always evaluates to null

痞子三分冷 提交于 2019-12-01 11:11:13
I am having a problem with @Cacheable and using a custom key based on Spring expression language. I have the following code @Cacheable(value = "myCache", key = "#providerDTO.identifier") ClientVO loadClientVOByProviderDTO(ProviderDTO providerDTO); This is throwing the following error org.springframework.expression.spel.SpelEvaluation Exception: EL1007Epos 0): Field or property 'identifier' cannot be found on null The providerDTO argument is not null, I have verified this many times. The docs say that this should work so I am very confused. The docs give the following example @Cacheable(value=

SpelEvaluationException Method cannot be found

a 夏天 提交于 2019-12-01 10:16:23
问题 I am facing with the next problem, when I am trying to pass the User to the service method using SpEL, evaluate expression="commonService.userTest(user)" result="flowScope.user" spring throws me the following exception: org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 14): Method call: Method userTest(com.x.domain.common.User) cannot be found on com.sun.proxy.$Proxy114 type But when I am passing a plain text instead of the User object, evaluate expression=

No bean resolver registered in the context to resolve access to bean

北城以北 提交于 2019-12-01 02:40:50
I'm trying to implement method security using Java Config, but I'm getting a error:- org.springframework.expression.spel.SpelEvaluationException: EL1057E:(pos 1): No bean resolver registered in the context to resolve access to bean 'appPermissionEvaluator' The method is:- @PreAuthorize("@appPermissionEvaluator.hasSystemPermission()") public String something() { ... } The Config class definition is (MethodSecurityConfig.java):- @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true) public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration { @Bean public