1
<display:table export="true"  id="data" name="${sessionScope.forbesList}"requestURI="">


                <a href="#" rel="tooltip" content="<span>

                        Name:<s:property value="#data.rank" /><br/>
                        Email: <a><s:property value="#data.name" /></a><br/>
                        Phone:<s:property value="#data.age" /> </span>">   <display:column property="rank" title="Rank" sortable="true"   /></a>
        <display:column property="name" title="Name" sortable="true"  />
        <display:column property="age" title="Age" sortable="true"  />

    </display:table>

在 Struts 2 中,我尝试在<s:property>标签内使用标签,<display :column>但我只能看到<display:column>值,而不是我访问的值<s:property>。怎么做?

4

1 回答 1

0

#1: Anchor (<A>) Tag does not have any content attribute.

Please refer to the documentation to see which attributes it supports and how to use them.


#2: in HTML, when putting the character " into an attribute of a Tag, you can:

  • substitute " with ', like in
    • myAttribute="this is 'right'" or
    • myAttribute='this is "right" too', or
  • encode the " with the html entity &quot;, like in
    • myAttribute="this is &quot;right&quot;"

You must encode the < and > too, with &lt; (Less Than) or &gt; (Greater Than).


#3: that said, you could put your HTML inside the Anchor Tag, in the place where it is supposed to be inserted, like :

<a href="#" rel="tooltip"> 
      Name:<s:property value="#data.rank" />
</a>

but, in your case, you are injecting a lot of HTML, including another Anchor, that is not possible. I think you should simply use a div or something similar as a container, like:

<div rel="tooltip" >
   <span>
      Name:<s:property value="#data.rank" /><br/>
      Email: <a><s:property value="#data.name" /></a><br/>
      Phone:<s:property value="#data.age" /> 
   </span>
</div>

Resolve this before worrying about DisplayTag


EDIT

#4 Change

<s:property value="#data.rank" />

(and all the other tags) to

<s:property value="#attr.data.rank" />

#attr is the OGNL used to access the pageContext,

if it is available, otherwise it searches request, session and application scopes.

于 2013-01-09T19:00:13.590 回答