struts2官网对于标签属性有如下描述:Boiled down, the tag attributes are evaluated using three rules.1.All String attribute types are parsed for the "%{ ... }" notation. 
2.All non-String attribute types are not parsed, but evaluated directly as an expression 
3.The exception to rule #2 is that if the non-String attribute uses the escape notion "%{}", the notation is ignored as redundant, and the content evaluated. 
谁能给解释一下具体含义,不是简单的翻译成中文。

解决方案 »

  1.   

    规则一:
     有字符串属性,且字符串属性方法%{}中,那么字符串属性将作为表达式执行,返回结果,而不是返回字符本身.
    例如:<s:url action="helloworld" namespace="/test">  指向helloworld.action
       <s:url action="%{helloworld}" namespace="/test"> 执行helloword属性值.action
    例如:
    <s:set name="myurl" value="'http://www.foshanshop.net'"/>
    <s:url value="#myurl" /><br>
    <s:url value="%{#myurl}" />
    输出结果:
    #myurl
    http://www.foshanshop.net规则二:
     非字符类属性直接被解析(OGNL表达式)计算出结果返回.规则三:
      如果规则二中的非字符属性放在${}中,%{}不起作用,和不加%{}一样.忽略%{}后,执行规则二.
    例如:构建MAp
    <s:set name="foobar" value="#{'foo1':'bar','foo2':'bar2'}" />

    <s:set name="foobar" value="%{#{'foo1':'bar','foo2':'bar2'}}" />
    等价
     
      

  2.   

    %{}  把字符串 强制解析成 OGNL 表达式 
    #{}  按照字符串格式 解析成集合
    ${}  el 表达式
      

  3.   

    就是说%,#,$的用法咯.!
    %{}表示大括号内的内容按照OGNL去解析.!因为struts2的UI标签的value属性不会作为OGNL解析,但有的时候必须用OGNL,这个时候就需要%{}标识它
    #{}可以构造map, #attrName表示取ognlContext中属性的值
    ${}这个符号表示是在配置文件中ognl的形式
      

  4.   

    5楼已经回答了你的第二个问题了,至于第一个问题“1.规则中的字符类和非字符类我怎么区分”。字符类和非字符类是指标签属性的取值。你可以查看struts2的文档,里面有关于标签属性的值的类型,如果为String就是字符。。不是的话就是非字符了!
      

  5.   

    规则一:
     有字符串属性,且字符串属性方法%{}中,那么字符串属性将作为表达式执行,返回结果,而不是返回字符本身.
    例如:<s:url action="helloworld" namespace="/test"> 指向helloworld.action
      <s:url action="%{helloworld}" namespace="/test"> 执行helloword属性值.action
    例如:
    <s:set name="myurl" value="'http://www.foshanshop.net'"/>
    <s:url value="#myurl" /><br>
    <s:url value="%{#myurl}" />
    输出结果:
    #myurl
    http://www.foshanshop.net规则二:
     非字符类属性直接被解析(OGNL表达式)计算出结果返回.规则三:
      如果规则二中的非字符属性放在${}中,%{}不起作用,和不加%{}一样.忽略%{}后,执行规则二.
    例如:构建MAp
    <s:set name="foobar" value="#{'foo1':'bar','foo2':'bar2'}" />

    <s:set name="foobar" value="%{#{'foo1':'bar','foo2':'bar2'}}" />
    等价
    说的真的蛮好的。up