Velocity 的应用示例
System.err.println(msg o);
}
public static Properties initServletEnvironment(VelocityServlet v)
{
// init only onceif (m_servletConfig != null)
{
return m_servletConfig;
}
//debugPrintln("initServletEnvironment....");
try
{
/* *call the overridable method to allow the *derived classes a shot at altering the configuration *before initializing Runtime */Properties p = new Properties();
ServletConfig config = v.getServletConfig();
// Set the Velocity.FILE_RESOURCE_LOADED_PATH property// to the root directory of the context.String path = config.getServletContext().getRealPath("/");
//debugPrintln("real path of / is : " path);
p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);
// Set the Velocity.RUNTIME_LOG property to be the file// velocity.log relative to the root directory// of the context.p.setProperty(Velocity.RUNTIME_LOG, path "velocity.log");
// Return the Properties object.//return p;
Velocity.init(p);
m_servletConfig = p;
return p;
}
catch (Exception e)
{
debugPrintln(e.getMessage());
//throw new ServletException("Error initializing Velocity: " e);
}
return null;
//this.getServletContext().getRealPath("/");
}
文章评论
共有位Admini5网友发表了评论 查看完整内容