类 VelocityLayoutServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.apache.velocity.tools.view.VelocityViewServlet
org.apache.velocity.tools.view.VelocityLayoutServlet
所有已实现的接口:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

public class VelocityLayoutServlet extends VelocityViewServlet
Extension of the VelocityViewServlet to perform "two-pass" layout rendering and allow for a customized error screen.
版本:
$Id$
作者:
Nathan Bubna
另请参阅:
  • 字段详细资料

    • PROPERTY_ERROR_TEMPLATE

      public static final String PROPERTY_ERROR_TEMPLATE
      The velocity.properties key for specifying the servlet's error template.
      另请参阅:
    • PROPERTY_LAYOUT_DIR

      public static final String PROPERTY_LAYOUT_DIR
      The velocity.properties key for specifying the relative directory holding layout templates.
      另请参阅:
    • PROPERTY_DEFAULT_LAYOUT

      public static final String PROPERTY_DEFAULT_LAYOUT
      The velocity.properties key for specifying the servlet's default layout template's filename.
      另请参阅:
    • DEFAULT_ERROR_TEMPLATE

      public static final String DEFAULT_ERROR_TEMPLATE
      The default error template's filename.
      另请参阅:
    • DEFAULT_LAYOUT_DIR

      public static final String DEFAULT_LAYOUT_DIR
      The default layout directory
      另请参阅:
    • DEFAULT_DEFAULT_LAYOUT

      public static final String DEFAULT_DEFAULT_LAYOUT
      The default filename for the servlet's default layout
      另请参阅:
    • KEY_SCREEN_CONTENT

      public static final String KEY_SCREEN_CONTENT
      The context key that will hold the content of the screen. This key ($screen_content) must be present in the layout template for the current screen to be rendered.
      另请参阅:
    • KEY_LAYOUT

      public static final String KEY_LAYOUT
      The context/parameter key used to specify an alternate layout to be used for a request instead of the default layout.
      另请参阅:
    • KEY_ERROR_CAUSE

      public static final String KEY_ERROR_CAUSE
      The context key that holds the Throwable that broke the rendering of the requested screen.
      另请参阅:
    • KEY_ERROR_STACKTRACE

      public static final String KEY_ERROR_STACKTRACE
      The context key that holds the stack trace of the error that broke the rendering of the requested screen.
      另请参阅:
    • KEY_ERROR_INVOCATION_EXCEPTION

      public static final String KEY_ERROR_INVOCATION_EXCEPTION
      The context key that holds the MethodInvocationException that broke the rendering of the requested screen. If this value is placed in the context, then $error_cause will hold the error that this invocation exception is wrapping.
      另请参阅:
    • PROPERTY_DYNAMIC_LAYOUT

      public static final String PROPERTY_DYNAMIC_LAYOUT
      The velocity.properties key for specifying whether dynamic layout change is allowed
      另请参阅:
    • errorTemplate

      protected String errorTemplate
    • layoutDir

      protected String layoutDir
    • defaultLayout

      protected String defaultLayout
  • 构造器详细资料

    • VelocityLayoutServlet

      public VelocityLayoutServlet()
  • 方法详细资料

    • init

      public void init(jakarta.servlet.ServletConfig config) throws jakarta.servlet.ServletException
      Initializes Velocity, the view servlet and checks for changes to the initial layout configuration.
      指定者:
      init 在接口中 jakarta.servlet.Servlet
      覆盖:
      init 在类中 VelocityViewServlet
      参数:
      config - servlet configuration parameters
      抛出:
      jakarta.servlet.ServletException
    • fillContext

      protected void fillContext(org.apache.velocity.context.Context ctx, jakarta.servlet.http.HttpServletRequest request)
      Overrides VelocityViewServlet to check the request for an alternate layout
      覆盖:
      fillContext 在类中 VelocityViewServlet
      参数:
      ctx - context for this request
      request - client request
    • findLayout

      protected String findLayout(jakarta.servlet.http.HttpServletRequest request)
      Searches for a non-default layout to be used for this request. This implementation checks the request parameters and attributes.
      参数:
      request - servlet request
      返回:
      layout name or null
    • mergeTemplate

      protected void mergeTemplate(org.apache.velocity.Template template, org.apache.velocity.context.Context context, jakarta.servlet.http.HttpServletResponse response) throws IOException
      Overrides VelocityViewServlet.mergeTemplate to do a two-pass render for handling layouts
      覆盖:
      mergeTemplate 在类中 VelocityViewServlet
      参数:
      template - Template object
      context - Velocity context
      response - servlet response
      抛出:
      IOException
    • error

      protected void error(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Throwable e)
      Overrides VelocityViewServlet to display user's custom error template
      覆盖:
      error 在类中 VelocityViewServlet
      参数:
      request - servlet request
      response - servlet response
      e - thrown error