类 ViewControllerRegistry

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

public class ViewControllerRegistry extends cn.taketoday.context.support.ApplicationObjectSupport
Assists with the registration of simple automated controllers pre-configured with status code and/or a view.
从以下版本开始:
4.0 2022/2/18 22:20
作者:
Rossen Stoyanchev, Keith Donald, Harry Yang
  • 字段详细资料

  • 构造器详细资料

    • ViewControllerRegistry

      public ViewControllerRegistry(cn.taketoday.context.ApplicationContext applicationContext)
      Class constructor with ApplicationContext.
  • 方法详细资料

    • addViewController

      public ViewControllerRegistration addViewController(String pathPattern)
      Map a URL path or pattern to a view controller to render a response with the configured status code and view.

      Patterns such as "/admin/**" or "/articles/{articlename:\\w+}" are supported.

      Note: If an @RequestMapping method is mapped to a URL for any HTTP method then a view controller cannot handle the same URL. For this reason it is recommended to avoid splitting URL handling across an annotated controller and a view controller.

    • addViewController

      public ViewControllerRegistration addViewController(String pathPattern, Object resource)
      Map a view controller to the given URL path (or pattern) in order to render a response with a pre-configured status code and view.

      Patterns like "/articles/**" or "/articles/{id:\\w+}" are allowed. See AntPathMatcher for more details on the syntax.

      参数:
      pathPattern - Patterns like "/articles/**" or "/articles/{id:\\w+}" are allowed. See AntPathMatcher for more details on the syntax.
      resource - resource location,such as redirect url or view template resource Or other type of resource
    • addRedirectViewController

      public RedirectViewControllerRegistration addRedirectViewController(String pathPattern, String redirectUrl)
      Map a view controller to the given URL path or pattern in order to redirect to another URL.

      By default the redirect URL is expected to be relative to the current ServletContext, i.e. as relative to the web application root.

    • addStatusController

      public void addStatusController(String pathPattern, HttpStatusCode statusCode)
      Map a simple controller to the given URL path (or pattern) in order to set the response status to the given code without rendering a body.
    • addStatusController

      public void addStatusController(String pathPattern, Integer status)
      Map a simple controller to the given URL path (or pattern) in order to set the response status to the given code without rendering a body.
    • registerWebViewXml

      public void registerWebViewXml()
      Map a URL path or pattern to a view controller to render a response with the configured status code and view.

      Patterns such as "/admin/**" or "/articles/{articlename:\\w+}" are supported.

      Note: If an @RequestMapping method is mapped to a URL for any HTTP method then a view controller cannot handle the same URL. For this reason it is recommended to avoid splitting URL handling across an annotated controller and a view controller.

    • registerWebViewXml

      public void registerWebViewXml(cn.taketoday.core.io.Resource resource)
    • setOrder

      public void setOrder(int order)
      Specify the order to use for the HandlerMapping used to map view controllers relative to other handler mappings configured in Framework MVC.

      By default this is set to 1, i.e. right after annotated controllers, which are ordered at 0.

    • buildHandlerMapping

      @Nullable protected SimpleUrlHandlerMapping buildHandlerMapping()
      Return the HandlerMapping that contains the registered view controller mappings, or null for no registrations.
    • configure

      protected void configure(cn.taketoday.core.io.Resource resource) throws Exception
      configure from a xml file
      抛出:
      Exception
      另请参阅:
      • StringUtils.split(String)
      • StringUtils.isSplitable(char)
    • configController

      protected void configController(Element controller)
      Start configuration
      参数:
      controller - the controller element
      从以下版本开始:
      2.3.7
    • processAction

      protected void processAction(String prefix, String suffix, Element action)
    • resolveEmbeddedVariables

      protected String resolveEmbeddedVariables(String expression)
      从以下版本开始:
      3.0.3