struts2 - OGNL

<s:debug></s:debug>

有两个区域 :Value Stack Contents和Stack Context

 

$:用于i18n和struts配置文件

  <action name="AddPhoto" class="addPhoto"> 

                  <interceptor-ref name="fileUploadStack" />             

                  <result type="redirect">ListPhotos.action?albumId=${albumId}</result> 

  </action>


#:读取Stack Context里面的内容 (Value Stack Contents里面的内容直接访问变量名就可以了)

    #相当于ActionContext.getContext()    

    ActionContext(类似于jsp - EL里面的pageContext很重要)


%:%{#username} 这个百分号是强制的把里面的变量当作OGNL表达式防止它当作字符串

 

<s:property/> 遍历那里面的每个元素

 

//struts2 tags  查看标签的参数类型,当参数类型为Object时,会把它解析为OGNL表达式

//因为 value为object类型,所以它会解析成object类型,要想把它解析成字符串,需要打上单引号

//set设置值默认scope是放在action里面就是request和actionContext(在Stack Context区域)里面
<s:set var="aa" value="'字符串'"></s:set>

 

http://hi.baidu.com/tommyhi/item/d810261a5878c57c7b5f25ca

posted on 2013-05-27 10:49  lovebeauty  阅读(163)  评论(0编辑  收藏  举报

导航