In jsp, I have:
<s:set name="gender" value="#{'':'gender', 'm':'Male', 'f':'Female'}"/>
The property user.gender
can be empty, m
, or f
. What I want is to display either Male
or Female
from the defined gender
map.
I tried <s:property value="gender[%{#user.gender}]"/>
but didn't work.
Single-quoted, single-characters in OGNL are actual char
s, not String
s.
If the user's gender is a String
the map should use double-quoted, single-characters as the key.
您需要使用#
符号来访问在<s:set>
标记中设置的值。
<s:property value="#gender[user.gender]"/>
try this
<s:property value="getText('properties.name')"/> //this is to fetch value from properties file
so answer to your question is sumthing like this
<s:property value="getText('user.gender')"/>
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.