I’m new to struts2 and confused by the ‘#’,’%’ and ‘$’ element. There are some usages like:
${user.name}
%{user.name}
<s:radio list="#{key1:value1,key2:value2}" />
Could any give me an explanation and examples?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To put it simply
If ${user.name} in jsp page, it is an EL expression.
If ${user.name} in struts.xml, it is an OGNL expression.
If %{user.name} in jsp page, it is an OGNL expression.
Final, #{key1:value1,key2:value2} is an OGNL expression, it means creates a map that maps the key1 to the value1 and key2 to the value2.
BTW: #{key1:value1,key2:value2} should be wrap in %{}, like %{#{key1:value1,key2:value2}}, however, some attributes in struts2 tags will assume that is OGNL expression, that means without %{} is OK.