【问题标题】:XWIKI velocity script not workingXWIKI 速度脚本不起作用
【发布时间】:2019-01-09 17:51:40
【问题描述】:

在 xwiki 9.8 上工作并复制下面为速度宏编写的相同代码,但它不起作用。显示一些错误。 是否有 ant per-requisit 来运行速度脚本。如果有,请告诉我。

{{velocity}}
Welcome $xcontext.user !
#if($hasAdmin)
you will see the following picture because you are an administrator:
image:picture.jpg
#end
{{/velocity}}

在输出中显示已添加的图片。 但它没有显示给出错误。

【问题讨论】:

  • 我看不出你的代码有什么问题,但如果没有错误就很难说。
  • 我是否需要添加一些扩展或 jar 文件才能让速度工作。
  • 我看不到添加的图片。也许您不是管理员用户并且缺乏“脚本”权限 - 这是使用速度宏所必需的。

标签: xwiki


【解决方案1】:

不清楚你想要实现什么,有什么问题。代码看起来不错,而且运行良好。

如果您想向非管理员用户添加一些错误,您应该包含一个#else 块。示例(包括检查 #elseif 分支上的访客用户):

{{velocity}}
Welcome $xcontext.user !
#if($hasAdmin)
  You will see the following picture because you are an administrator:
  image:picture.jpg
#elseif ("$!xcontext.userReference" == '')
  {{error}}You need to [[login>>path:$xwiki.getURL('XWiki.XWikiLogin', 'login', "xredirect=$doc.getURL()")]] to access this section.{{/error}}
#else
  {{error}}You need admin rights to access this section.{{/error}}
#end
{{/velocity}}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多