简体   繁体   English

速度的全局上下文

[英]Global context in velocity

I'd like to define global variables in velocity. 我想定义速度的全局变量。 I had a look at VelocityTools but I'm afraid the tools don't help. 我看了一下VelocityTools,但恐怕这些工具无济于事。 The ContextTool I found here doesn't offer methos for putting data into the Context. 我在这里找到的ContextTool没有提供将数据放入Context的方法。 Only methods for getting data from the context are available. 仅提供从上下文中获取数据的方法。 Is this the wrong tool for getting AND putting data? 这是获取和放置数据的错误工具吗? Is there another tool for this purpose? 是否有用于此目的的另一种工具?

Thank you in advance. 先感谢您。

It is the correct tool for your purpose. 这是适合您目的的正确工具。 You can access the context using the getThis() method: 您可以使用getThis()方法访问上下文:

contextTool.getThis().put("variable", variable);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM