Spring Class_04.2020_CORE_SpEL Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is SpEL?

A

Spring expression language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What can SpEL expression can be used for?

A

defining BeanDefinitions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is syntax to define SpEL expression?

A
#{} 
${spring.version}  (in maven)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Bean reference using SpEL

A

@Value(«#{countryBean}»)
private Country country;

(используется id из application-context.xml)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Method invocation using SpEL

A

Value = «#{countryBean.toString()}»

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Operators using SpEL

A

Name = «equalTest» Value = «#{countryBean == 100}»

return boolean and set it in field with name «equalTest»

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to use regex with spell?

A

use word ‘matches’

#{(‘100’ matches ‘\d+’)}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does ExpressionParser do?

A

allows to get value of bean fields

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the context used by ExpressionParser?

A

SEC

StandarsEvaluationContext

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is used as parameter for parseExpresion() method?

A

name of field

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is used as parameter for getValue() method of ExcpressionParser?

A

instance of SEC (StandarsEvaluationContext) and type of field (ex. String.class)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Example of expression parser using

A
Bank bank = new Bank(«Alfa bank»); StandarsEvaluationContext bankContext = new StandarsEvaluationContext(bank); 
String bankName = parser.parseExpression(«name»).getValue(bankContext, String.class);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly