- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在linux下工作,在我的应用程序中,我限制了权限,所有路径都是只读的
在我的应用程序中,我使用了 velocity-1.6.2.jar 并且每次调用它时都会创建 velocity.log 并且该文件应该是可读/可写的。
对于这个问题我尝试禁用速度日志
我尝试在速度属性中添加这一行:
runtime.log.logsystem.class=org.apache.velocity.runtime.log.NullLogSystem
但是我有这个错误:
org.apache.velocity.exception.VelocityException: Failed to initialize an instance of org.apache.velocity.runtime.log.Log4JLogChute with the current runtime configuration.
org.apache.velocity.runtime.log.LogManager.createLogChute(LogManager.java:206)
org.apache.velocity.runtime.log.LogManager.updateLog(LogManager.java:255)
org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:795)
org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:250)
org.apache.velocity.runtime.RuntimeSingleton.init(RuntimeSingleton.java:114)
org.apache.velocity.app.Velocity.init(Velocity.java:79)
这是文件速度属性
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# R U N T I M E L O G
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# default LogChute to use: default: AvalonLogChute, Log4JLogChute, CommonsLogLogChute, ServletLogChute, JdkLogChute
# ----------------------------------------------------------------------------
runtime.log.logsystem.class = org.apache.velocity.runtime.log.AvalonLogChute,org.apache.velocity.runtime.log.Log4JLogChute,org.apache.velocity.runtime.log.CommonsLogLogChute,org.apache.velocity.runtime.log.ServletLogChute,org.apache.velocity.runtime.log.JdkLogChute
# ---------------------------------------------------------------------------
# This is the location of the Velocity Runtime log.
# ----------------------------------------------------------------------------
runtime.log = velocity.log
# ----------------------------------------------------------------------------
# This controls whether invalid references are logged.
# ----------------------------------------------------------------------------
runtime.log.invalid.references = true
# ----------------------------------------------------------------------------
# T E M P L A T E E N C O D I N G
# ----------------------------------------------------------------------------
input.encoding=ISO-8859-1
output.encoding=ISO-8859-1
# ----------------------------------------------------------------------------
# F O R E A C H P R O P E R T I E S
# ----------------------------------------------------------------------------
# These properties control how the counter is accessed in the #foreach
# directive. By default the reference $velocityCount and $velocityHasNext
# will be available in the body of the #foreach directive.
# The default starting value for $velocityCount is 1.
# ----------------------------------------------------------------------------
directive.foreach.counter.name = velocityCount
directive.foreach.counter.initial.value = 1
directive.foreach.maxloops = -1
directive.foreach.iterator.name = velocityHasNext
# ----------------------------------------------------------------------------
# S E T P R O P E R T I E S
# ----------------------------------------------------------------------------
# These properties control the behavior of #set.
# For compatibility, the default behavior is to disallow setting a reference
# to null. This default may be changed in a future version.
# ----------------------------------------------------------------------------
directive.set.null.allowed = false
# ----------------------------------------------------------------------------
# I N C L U D E P R O P E R T I E S
# ----------------------------------------------------------------------------
# These are the properties that governed the way #include'd content
# is governed.
# ----------------------------------------------------------------------------
directive.include.output.errormsg.start = <!-- include error :
directive.include.output.errormsg.end = see error log -->
# ----------------------------------------------------------------------------
# P A R S E P R O P E R T I E S
# ----------------------------------------------------------------------------
directive.parse.max.depth = 10
# ----------------------------------------------------------------------------
# T E M P L A T E L O A D E R S
# ----------------------------------------------------------------------------
#
#
# ----------------------------------------------------------------------------
resource.loader = file
file.resource.loader.description = Velocity File Resource Loader
file.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoader
file.resource.loader.path = .
file.resource.loader.cache = false
file.resource.loader.modificationCheckInterval = 2
# ----------------------------------------------------------------------------
# VELOCIMACRO PROPERTIES
# ----------------------------------------------------------------------------
# global : name of default global library. It is expected to be in the regular
# template path. You may remove it (either the file or this property) if
# you wish with no harm.
# ----------------------------------------------------------------------------
# velocimacro.library = VM_global_library.vm
velocimacro.permissions.allow.inline = true
velocimacro.permissions.allow.inline.to.replace.global = false
velocimacro.permissions.allow.inline.local.scope = false
velocimacro.context.localscope = false
velocimacro.max.depth = 20
# ----------------------------------------------------------------------------
# VELOCIMACRO STRICT MODE
# ----------------------------------------------------------------------------
# if true, will throw an exception for incorrect number
# of arguments. false by default (for backwards compatibility)
# but this option will eventually be removed and will always
# act as if true
# ----------------------------------------------------------------------------
velocimacro.arguments.strict = false
# ----------------------------------------------------------------------------
# STRICT REFERENCE MODE
# ----------------------------------------------------------------------------
# if true, will throw a MethodInvocationException for references
# that are not defined in the context, or have not been defined
# with a #set directive. This setting will also throw an exception
# if an attempt is made to call a non-existing property on an object
# or if the object is null. When this property is true then property
# 'directive.set.null.allowed' is also set to true.
# ----------------------------------------------------------------------------
runtime.references.strict = false
# ----------------------------------------------------------------------------
# INTERPOLATION
# ----------------------------------------------------------------------------
# turn off and on interpolation of references and directives in string
# literals. ON by default :)
# ----------------------------------------------------------------------------
runtime.interpolate.string.literals = true
# ----------------------------------------------------------------------------
# RESOURCE MANAGEMENT
# ----------------------------------------------------------------------------
# Allows alternative ResourceManager and ResourceCache implementations
# to be plugged in.
# ----------------------------------------------------------------------------
resource.manager.class = org.apache.velocity.runtime.resource.ResourceManagerImpl
resource.manager.cache.class = org.apache.velocity.runtime.resource.ResourceCacheImpl
# ----------------------------------------------------------------------------
# PARSER POOL
# ----------------------------------------------------------------------------
# Selects a custom factory class for the parser pool. Must implement
# ParserPool. parser.pool.size is used by the default implementation
# ParserPoolImpl
# ----------------------------------------------------------------------------
parser.pool.class = org.apache.velocity.runtime.ParserPoolImpl
parser.pool.size = 20
# ----------------------------------------------------------------------------
# EVENT HANDLER
# ----------------------------------------------------------------------------
# Allows alternative event handlers to be plugged in. Note that each
# class property is actually a comma-separated list of classes (which will
# be called in order).
# ----------------------------------------------------------------------------
# eventhandler.referenceinsertion.class =
# eventhandler.nullset.class =
# eventhandler.methodexception.class =
# eventhandler.include.class =
# ----------------------------------------------------------------------------
# EVALUATE
# ----------------------------------------------------------------------------
# Evaluate VTL dynamically in template. Select a class for the Context
# ----------------------------------------------------------------------------
directive.evaluate.context.class = org.apache.velocity.VelocityContext
# ----------------------------------------------------------------------------
# PLUGGABLE INTROSPECTOR
# ----------------------------------------------------------------------------
# Allows alternative introspection and all that can of worms brings.
# ----------------------------------------------------------------------------
runtime.introspector.uberspect = org.apache.velocity.util.introspection.UberspectImpl
# ----------------------------------------------------------------------------
# SECURE INTROSPECTOR
# ----------------------------------------------------------------------------
# If selected, prohibits methods in certain classes and packages from being
# accessed.
# ----------------------------------------------------------------------------
introspector.restrict.packages = java.lang.reflect
# The two most dangerous classes
introspector.restrict.classes = java.lang.Class
introspector.restrict.classes = java.lang.ClassLoader
# Restrict these for extra safety
introspector.restrict.classes = java.lang.Compiler
introspector.restrict.classes = java.lang.InheritableThreadLocal
introspector.restrict.classes = java.lang.Package
introspector.restrict.classes = java.lang.Process
introspector.restrict.classes = java.lang.Runtime
introspector.restrict.classes = java.lang.RuntimePermission
introspector.restrict.classes = java.lang.SecurityManager
introspector.restrict.classes = java.lang.System
introspector.restrict.classes = java.lang.Thread
introspector.restrict.classes = java.lang.ThreadGroup
introspector.restrict.classes = java.lang.ThreadLocal
runtime.log.logsystem.class=org.apache.velocity.runtime.log.NullLogSystem
更新:
我也尝试在 velocity properties
中评论其他行#runtime.log.logsystem.class = org.apache.velocity.runtime.log.AvalonLogChute,org.apache.velocity.runtime.log.Log4JLogChute,org.apache.velocity.runtime.log.CommonsLogLogChute,org.apache.velocity.runtime.log.ServletLogChute,org.apache.velocity.runtime.log.JdkLogChute
但我还有其他错误:
java.lang.NullPointerException
org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1103)
org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1086)
org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1199)
org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1165)
org.apache.velocity.app.Velocity.evaluate(Velocity.java:191)
最佳答案
您正在使用 NullLogSystem,它是 Deprecated class , 如果你真的想要
Logger used in case of failure. Does nothing.
使用org.apache.velocity.runtime.log.NullLogChute ,在 velocity.properties
中:
runtime.log.logsystem.class=org.apache.velocity.runtime.log.NullLogChute
或者,可以在您的 VelocityEngine 实例上以编程方式设置此属性:
VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine.setProperty("runtime.log.logsystem.class", NullLogChute.class.getName());
另见 dependencies对于 velocity 1.6.2 并检查你是否有相关版本。
关于velocity - 无法使用当前运行时配置初始化 org.apache.velocity.runtime.log.Log4JLogChute 的实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46618129/
有没有办法在 Velocity 中做三元运算符? 这就是我想做的: #set ($name = ($args.get(0) == "") ? "default" : $args.get(0)) 而不是
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 4年前关闭。 Improve this qu
我有一个 Java 数组,例如: String[] arr = new String[] {"123","doc","projectReport.doc"}; 在我看来,访问的自然方式是: #set
拥有: Velocity 模板或宏 某个物体 如何以易于追踪到失败位置(例如在 Java 中抛出异常)的方式验证对象 (#if) 并失败(停止进一步处理)。 我正在寻找这样的东西: #if ( ! $
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
在 xwiki 中使用 Apache velocity,如何像在 JavaScript 中那样创建一个 console.log()?我知道日志可能会在服务器端。我真的只想打印为调试目的而呈现的变量值。
我有一个 Velocity 模板文件,其中包含来自 XML 的数据。我想将字符串转换为整数类型。 我怎样才能做到这一点? 最佳答案 啊哈!去过那里。 #set($intString = "9") #s
您如何在 Velocity 中获得查询中第一项的输出。例如,如果您的查询是 $Items 并且包含许多对象,您如何获得第一个? 我试过 $Items(1) 但这不是答案。有什么建议?谢谢你。 最佳答案
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
是否可以通过名称调用速度宏,例如: #macro (sayHello) Hello! #end #set ($macroName = "sayHello") #$macroName() 谢谢! 最佳
我对在 if 语句中处理多个和/或语句感到有点困惑。我希望有人能帮我解决这个问题。 Velocity 引用指南似乎没有解决我正在尝试做的事情。 我正在使用一个应用程序,我将在其中使用公共(public
我在包含一些路径的速度模板中设置了一个数组。 这个想法是在这个数组中放置一些“默认”的 .js/.css 文件,90% 的页面将使用这些文件。 但是,其他页面仍然必须能够从该数组中添加/删除值,以防根
我试图通过在初始请求下载的 HTML 中内联一些 CSS 来优化一些移动网页(或更准确的服务器请求数量)。 这些页面来自我们基于 Vosao 的 CMS,并使用 Apache Velocity 宏。
如果在VelocityContext中没有找到值,Velocity只会打印标签名称,即我的模板文件中的$name,但是VelocityContext中没有“name”的值,所以只打印了“$name”。
Marketo 限制了 10 个最近的可搜索机会,不幸的是,我们有很多用户拥有超过 10 个机会。 foreach 循环似乎从最近最少更新的机会开始,并在列表中向上移动到最近更新的机会。这里的问题是,
如何在 Velocity 模板引擎中将十进制数四舍五入到 2 位? #set ($Percentage = $Marks*100/$Total) 我想将百分比四舍五入到小数点后两位。我怎样才能做到这一
我在扩展 AbstractProcessor 的注释处理器内初始化速度引擎,如下所示: public boolean process(Set annotations, RoundEnvironment
我有一个速度模板,它代表一个 XML 文件。我使用传递给 VelocityContext 对象的数据填充标签之间的文本。然后在模板中访问它。 这是一个例子,我们称之为 myTemplate.vm: $
我在linux下工作,在我的应用程序中,我限制了权限,所有路径都是只读的 在我的应用程序中,我使用了 velocity-1.6.2.jar 并且每次调用它时都会创建 velocity.log 并且该文
我正在尝试使用嵌入在 Atlassian 产品中的 Velocity 引擎(并通过 com.atlassian.templaterenderer 公开)将 JSON 值替换为模板。 在模板中,这看起来
我是一名优秀的程序员,十分优秀!