类 UrlFilenameViewController

java.lang.Object
cn.taketoday.context.support.ApplicationObjectSupport
所有已实现的接口:
cn.taketoday.beans.factory.Aware, cn.taketoday.context.ApplicationContextAware, Controller, HttpRequestHandler

public class UrlFilenameViewController extends AbstractUrlViewController
Simple Controller implementation that transforms the virtual path of a URL into a view name and returns that view.

Can optionally prepend a prefix and/or append a suffix to build the viewname from the URL filename.

Find some examples below:

  1. "/index" -> "index"
  2. "/index.html" -> "index"
  3. "/index.html" + prefix "pre_" and suffix "_suf" -> "pre_index_suf"
  4. "/products/view.html" -> "products/view"

Thanks to David Barri for suggesting prefix/suffix support!

从以下版本开始:
4.0 2022/2/8 17:06
作者:
Alef Arendsen, Juergen Hoeller, Rob Harrop, Harry Yang
另请参阅:
  • 字段详细资料

    • prefix

      private String prefix
    • suffix

      private String suffix
    • removeSemicolonContent

      private boolean removeSemicolonContent
    • viewNameCache

      private final Map<String,String> viewNameCache
      Request URL path String to view name String.
  • 构造器详细资料

    • UrlFilenameViewController

      public UrlFilenameViewController()
  • 方法详细资料

    • setPrefix

      public void setPrefix(@Nullable String prefix)
      Set the prefix to prepend to the request URL filename to build a view name.
    • getPrefix

      protected String getPrefix()
      Return the prefix to prepend to the request URL filename.
    • setSuffix

      public void setSuffix(@Nullable String suffix)
      Set the suffix to append to the request URL filename to build a view name.
    • getSuffix

      protected String getSuffix()
      Return the suffix to append to the request URL filename.
    • setRemoveSemicolonContent

      public void setRemoveSemicolonContent(boolean removeSemicolonContent)
      Set if ";" (semicolon) content should be stripped from the request URI.

      Default is "true".

    • getViewNameForRequest

      protected String getViewNameForRequest(RequestContext request)
      Returns view name based on the URL filename, with prefix/suffix applied when appropriate.
      指定者:
      getViewNameForRequest 在类中 AbstractUrlViewController
      参数:
      request - current HTTP request
      返回:
      a view name for this request (never null)
      另请参阅:
    • extractOperableUrl

      protected String extractOperableUrl(RequestContext request)
      Extract a URL path from the given request, suitable for view name extraction.
      参数:
      request - current HTTP request
      返回:
      the URL to use for view name extraction
    • getViewNameForUrlPath

      protected String getViewNameForUrlPath(String uri)
      Returns view name based on the URL filename, with prefix/suffix applied when appropriate.
      参数:
      uri - the request URI; for example "/index.html"
      返回:
      the extracted URI filename; for example "index"
      另请参阅:
    • extractViewNameFromUrlPath

      protected String extractViewNameFromUrlPath(String uri)
      Extract the URL filename from the given request URI.
      参数:
      uri - the request URI; for example "/index.html"
      返回:
      the extracted URI filename; for example "index"
    • postProcessViewName

      protected String postProcessViewName(String viewName)
      Build the full view name based on the given view name as indicated by the URL path.

      The default implementation simply applies prefix and suffix. This can be overridden, for example, to manipulate upper case / lower case, etc.

      参数:
      viewName - the original view name, as indicated by the URL path
      返回:
      the full view name to use
      另请参阅: