主题 : action_cms.ftl模板里@s.action 是哪里来的以及双问号
级别: 秀才
UID: 3879
积分:53 加为好友
威望: 0 精华: 0
主题:7 回复:13
注册时间:2010-03-03
在线时长:0
1#   发表于:2010-04-08 16:23:15  IP:124.50.*.*
1、在action_cms.ftl模板里@s.action 是哪里来的?
<@s.action name='ChnlList' namespace='/jeecms/tag/cms' executeResult='true'。。。

<#else>
<@s.action name='ChnlListInner' namespace='/jeecms/tag/cms' executeResult='false'。。。
这里的s 是从哪里定义来的?

2、 <#local customs = ' '>
<#list custom as s>
<#local customs = customs+s>
<#if s_has_next><#local customs = customs+'|'></#if>
</#list>
请说明上面语法local和此段代码的意思

3、common_tag.ftl里<#if c.parent??>双问号是怎么个意思啊?
谢谢
级别: 童生
UID: 1231
积分:42 加为好友
威望: 0 精华: 0
主题:4 回复:19
注册时间:2009-11-29
在线时长:0
2#   发表于:2010-05-15 10:47:18  IP:119.212.*.*
1、在action_cms.ftl模板里@s.action 是哪里来的? 
<@s.action name='ChnlList' namespace='/jeecms/tag/cms' executeResult='true'。。。 
和 
<#else> 
<@s.action name='ChnlListInner' namespace='/jeecms/tag/cms' executeResult='false'。。。 
这里的s 是从哪里定义来的? 

A:
这个是在freemarker.properties中的auto_import属性。

2、 <#local customs = ' '> 
<#list custom as s> 
<#local customs = customs+s> 
<#if s_has_next><#local customs = customs+'|'></#if> 
</#list> 
请说明上面语法local和此段代码的意思 

A:
local是定义变量,上边的代码相当于没有运行。因为customs='',里面的s_has_next就是系统自带的和java中的s.next()相当。

3、common_tag.ftl里<#if c.parent??>双问号是怎么个意思啊? 
A:
双问号的意思就是是否为空。if (c.parent == null)相当。
主机互联IDC产品发布。 http://www.icphost.com
级别: 白丁
UID: 7315
积分:5 加为好友
威望: 0 精华: 0
主题:0 回复:5
注册时间:2010-05-28
在线时长:0
3#   发表于:2010-06-10 22:34:09  IP:60.200.*.*
楼上的回答有误,更正一下:

1,"s"是定义在struts-default.xml中的
 <bean type="org.apache.struts2.views.TagLibrary" name="s" class="org.apache.struts2.views.DefaultTagLibrary" />
   具体的话看看Struts2和freemaker的关系吧

freemarker.properties中定义的auto_import是p和cms

2,local是定义变量
  具体可以参考 http://freemarker.sourceforge.net/docs/dgui_misc_var.html

     你提供的这段代码的作用是把custom散列中的数据中间加上"|" 后赋给变量customs 
例如:
     custom=['国内','国际','全部']
      那么customs ="国内|国际|全部"

3,判断是否为空

http://freemarker.sourceforge.net/docs/dgui_template_exp.html#dgui_template_exp_missing_test
1 共1页