本文整理了Java中freemarker.template.Configuration.setSharedVaribles()
方法的一些代码示例,展示了Configuration.setSharedVaribles()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.setSharedVaribles()
方法的具体详情如下:
包路径:freemarker.template.Configuration
类名称:Configuration
方法名:setSharedVaribles
[英]Replaces all shared variables (removes all previously added ones).
The values in the map can be TemplateModel-s or plain Java objects which will be immediately converted to TemplateModel with the ObjectWrapper returned by #getObjectWrapper(). If #setObjectWrapper(ObjectWrapper) is called later, this conversion will be re-applied. Thus, ignoring some extra resource usage, it doesn't mater if in what order are #setObjectWrapper(ObjectWrapper) and #setSharedVaribles(Map) called. This is essential when you don't have control over the order in which the setters are called.
The values in the map must be thread safe, if you are running templates from multiple threads with this configuration. This means that both the plain Java object and the TemplateModel-s created from them by the ObjectWrapper must be thread safe. (The standard ObjectWrapper-s of FreeMarker create thread safe TemplateModel-s.) The Map itself need not be thread-safe.
This setter method has no getter pair because of the tricky relation ship with #setSharedVariable(String,Object).
[中]
代码示例来源:origin: com.github.becauseQA/becauseQA-utils
shareVariables.put("Author", "Alter Hu");
try {
configuration.setSharedVaribles(shareVariables);
代码示例来源:origin: com.github.becausetesting/commons
shareVariables.put("Author", "Alter Hu");
try {
configuration.setSharedVaribles(shareVariables);
内容来源于网络,如有侵权,请联系作者删除!