EL,OGNL表达式 $ % #

1、OGNL表达式依赖于struts2标签,必须结合struts2标签使用,

%”符号的用途是在标志的属性为字符串类型时,计算OGNL表达式的值。

<s:a href="getThemeMsg.action?tea_id= %{#session.loginUser.teacher.tea_id}" cssClass="icoZwsc">作文上传</s:a>

访问session 包含loginUser的属性

<s:property value="#session.loginUser.teacher.tea_name" />

 

2、EL 提供了在 JSP脚本编制元素范围外使用运行时表达式的功能。

EL存取变量数据


 1 $(document).ready(
 2         
 3             function(){
 4              
 5              
 6              //显示提示信息
 7              var m = "${msg}";
 8              if(!checkIsNull(m))
 9              alert(m);
10              
11                  //显示等级图标
12              var rankScore="<%=score%>"
13                 //    alert(rankScore);
14              setRankPic(rankScore);
15             }
16         );
View Code

   

 3、OGNL  <s:property  (修改为#priviewList,就没值.)

    private Map<Integer,List<TurnPicTemp>> priviewList ;
    <img src="<s:property value='priviewList[2][0]["imagepath"]' />" alt="美味的欢乐"     class="absImg" style="top: 77px; left: 0px" />

      private Map<Integer,List<String>> priviewList ;
    <img src="<s:property value='priviewList[2][0]' />" alt="美味的欢乐"     class="absImg" style="top: 77px; left: 0px" />

 

参考资料:EL,OGNL两种表达式用处的不同

             Struts 2的OGNL表达式( # % $)

             EL表达式从数组 Map List集合取值

             s:propertyd的用法

            

posted @ 2014-09-03 14:09  菜枚  阅读(244)  评论(0编辑  收藏  举报