类 VelocityViewFilter

java.lang.Object
org.apache.velocity.tools.view.VelocityViewFilter
所有已实现的接口:
jakarta.servlet.Filter

public class VelocityViewFilter extends Object implements jakarta.servlet.Filter

A filter to ensure VelocityTools Toolboxes are available in the request/session/application scopes. This can simplify the process of integration with other frameworks.

VelocityViewFilter supports the following configuration parameters in web.xml:

org.apache.velocity.tools
Path and name of the toolbox configuration file. The path must be relative to the web application root directory. If this parameter is not found, the servlet will check for a toolbox file at '/WEB-INF/tools.xml'.
org.apache.velocity.properties
Path and name of the Velocity configuration file. The path must be relative to the web application root directory. If this parameter is not present, Velocity will check for a properties file at '/WEB-INF/velocity.properties'. If no file is found there, then Velocity is initialized with the settings in the classpath at 'org.apache.velocity.tools.view.velocity.properties'.
org.apache.velocity.tools.loadDefaults
By default, this is false. If set to true, then the default toolbox configuration will be added prior to your (if any) custom configuration.
org.apache.velocity.tools.cleanConfiguration
By default, this is false. If set to true, then then the final toolbox configuration (the combination of any custom one(s) provided by yourself and/or the default configuration(s)) will have all invalid tools, properties, and/or data removed prior to configuring the ToolboxFactory for this servlet by a ConfigurationCleaner
org.apache.velocity.tools.shared.config
By default, this is true. If set to false, then the VelocityView used by this filter will not be shared with other VelocityViewFilters, VelocityViewServlets or org.apache.velocity.tools.view.jsp.VelocityViewTag's in the application.
org.apache.velocity.tools.context.key
If you set a value for this property, this filter will create and prepare a ViewToolContext for each request, and then place it into the request attributes under the key you set. This is primarily for those who use this filter WITHOUT sharing a config (i.e. non-shared VelocityView), letting them retrieve the context as the request attribute.
org.apache.velocity.tools.view.class
Allows to specify a custom class (inheriting from VelocityView) as the View class.
版本:
$Id: VelocityViewFilter.java 611011 2008-01-11 01:32:59Z nbubna $
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static final String
     
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    protected org.apache.velocity.context.Context
    createContext(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
     
    void
     
    void
    doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain)
    Simply prepares the request (and/or session) toolbox(es) for other filters, servlets or whatnot to use.
    protected String
    Looks up an init parameter with the specified key in either the FilterConfig or, failing that, in the ServletContext.
    protected String
     
    protected jakarta.servlet.FilterConfig
     
    protected VelocityView
     
    void
    init(jakarta.servlet.FilterConfig config)
    Initializes VelocityView used to process requests.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

  • 构造器详细资料

    • VelocityViewFilter

      public VelocityViewFilter()
  • 方法详细资料

    • init

      public void init(jakarta.servlet.FilterConfig config) throws jakarta.servlet.ServletException

      Initializes VelocityView used to process requests. Called by the servlet container on loading.

      指定者:
      init 在接口中 jakarta.servlet.Filter
      参数:
      config - filter configuation
      抛出:
      jakarta.servlet.ServletException
    • getFilterConfig

      protected jakarta.servlet.FilterConfig getFilterConfig()
    • getVelocityView

      protected VelocityView getVelocityView()
    • getContextKey

      protected String getContextKey()
    • findInitParameter

      protected String findInitParameter(String key)
      Looks up an init parameter with the specified key in either the FilterConfig or, failing that, in the ServletContext.
      参数:
      key - init parameter key
      返回:
      found value or null
    • doFilter

      public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException
      Simply prepares the request (and/or session) toolbox(es) for other filters, servlets or whatnot to use. If a context key has been provided in the init-params of the filter or webapp, then this will also create a ViewToolContext and put it in the request attributes under that key.
      指定者:
      doFilter 在接口中 jakarta.servlet.Filter
      抛出:
      IOException
      jakarta.servlet.ServletException
    • createContext

      protected org.apache.velocity.context.Context createContext(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
    • destroy

      public void destroy()
      指定者:
      destroy 在接口中 jakarta.servlet.Filter