本文整理汇总了Java中org.apache.velocity.tools.Scope类的典型用法代码示例。如果您正苦于以下问题:Java Scope类的具体用法?Java Scope怎么用?Java Scope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Scope类属于org.apache.velocity.tools包,在下文中一共展示了Scope类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createVelocityContext
import org.apache.velocity.tools.Scope; //导入依赖的package包/类
@Override
protected Context createVelocityContext(Map<String, Object> model,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ViewToolContext velocityContext = new ViewToolContext(getVelocityEngine(), request, response, getServletContext());
velocityContext.putAll(model);
if(getToolboxConfigLocation() != null ||getToolboxConfigResource() != null){
XmlFactoryConfiguration cfg = new XmlFactoryConfiguration();
URL cfgUrl;
if(getToolboxConfigLocation() != null){
cfgUrl = new ServletContextResource(getServletContext(), getToolboxConfigLocation()).getURL();
cfg.read(cfgUrl);
}else if(getToolboxConfigResource() != null){
cfgUrl = getToolboxConfigResource().getURL();
cfg.read(cfgUrl);
ToolboxFactory factory = cfg.createFactory();
velocityContext.addToolbox(factory.createToolbox(Scope.APPLICATION));
velocityContext.addToolbox(factory.createToolbox(Scope.REQUEST));
velocityContext.addToolbox(factory.createToolbox(Scope.SESSION));
}
}
return velocityContext;
}
示例2: createContextForLocale
import org.apache.velocity.tools.Scope; //导入依赖的package包/类
private Context createContextForLocale(Locale locale) {
EasyFactoryConfiguration config = new EasyFactoryConfiguration();
config.toolbox(Scope.APPLICATION)
.tool(MSG, ResourceTool.class)
.property(BUNDLES, MESSAGES)
.property(LOCALE, locale);
ToolManager manager = new ToolManager(false, false);
manager.configure(config);
return manager.createContext();
}
示例3: ExtendableViewToolManager
import org.apache.velocity.tools.Scope; //导入依赖的package包/类
public ExtendableViewToolManager(ServletContext servletContext, boolean autoConfig,
boolean includeDefaults) {
super(servletContext, autoConfig, includeDefaults);
this.applicationToolboxConfiguration = new ToolboxConfiguration();
this.applicationToolboxConfiguration.setScope(Scope.APPLICATION);
this.requestToolboxConfiguration = new ToolboxConfiguration();
this.requestToolboxConfiguration.setScope(Scope.REQUEST);
applicationTools = new HashMap<>();
requestTools = new HashMap<>();
}