2013年9月28日星期六

EL expression $ {} nesting

Originally Direct $ {user.id} can get the value ,
But now I get from the database the User property of the presence of a variable inside $ {fid} = id $ {fname} = name
$ {user. $ {fid}} Do not do that . .

Will this situation how to do it ?
------ Solution ---------------------------------------- ----
looks like it can not be nested . Why would you do it ? In order to achieve loose coupling do ? It is not necessary .
------ Solution ---------------------------------------- ----
$ {user.fid}

or

$ {user ["fid"]}
------ Solution -------------------------- ------------------
Map map
# {user.map ['abc']}
------ Solution ------------------------- -------------------
LZ, do you want the interface to get the User 's ID? Can understand the point of your question . ( My User properties from the database to obtain the presence of a variable inside )
------ Solution -------------------------- ------------------


I looked back and forth several times , he just did not know what LZ want to achieve ?
------ Solution ---------------------------------------- ----
it is not, first use a variable to store , and then PageContext.getAttribute () and then taken out
------ For reference only ------------ ---------------------------

there is a need to control the page display fields. . . So to this
------ For reference only ----------------------------------- ----

not do so directly . It will be reported Property 'fid' not found on type com.entity.User
------ For reference only ------------- --------------------------

amount . . Just tried it or not eh . . Hey ~
------ For reference only ---------------------------------- -----

amount .. there is a User ID, ​​name these two properties , and now I'm not sure I want to show that field , so to check the database is to show ID or name. query results in a variable inside .. $ {fid} = id or $ {fname} = name;
interface shows how $ {user.name} = 'xx' now use $ {fname} instead of name $ {user. $ {fname}} ( Of course, this does not work ) . . .
------ For reference only -------------------------------------- -

. . . . . I can express myself so unclear ? Is to user.id the user id and the two variables were placed inside, and then how assembled into $ {user.id} this effect. . .
------ For reference only -------------------------------------- -
landlord should say , in dynamic properties of the user to take out
------ For reference only ------------------- --------------------
I finally understand the meaning of the landlord
because I also encountered this problem

tried many ways and finally get

Using struts-bean.tld "prefix =" bean "%>

perfect solution

没有评论:

发表评论