Class WebTemplateInterceptor

java.lang.Object
com.foreach.across.modules.web.template.WebTemplateInterceptor
All Implemented Interfaces:
org.springframework.web.servlet.HandlerInterceptor

public class WebTemplateInterceptor extends Object implements org.springframework.web.servlet.HandlerInterceptor
Finds and applies the web template configured to a particular request. Also provides support for partial rendering, though this assumes Thymeleaf templates.

Partial rendering
When a _partial parameter is present it will be parsed for a fragment and view element specification. The partial parameter can be of the following forms:

  • FRAGMENT: only the template fragment that should be rendered
  • ::VIEW_ELEMENT_NAME: only the name of the view element that should be rendered
  • FRAGMENT::VIEW_ELEMENT_NAME: both template fragment and name of the view element that should be rendered

In case a template fragment is specified, the web template itself will not be applied and the fragment will be automatically appended to the view returned by the controller.

In case a ViewElement name is specified, only the output of ViewElements with that name will be returned. You must ensure that the name is unique if you only want a single element rendered.

See Also:
  • Field Details

  • Constructor Details

    • WebTemplateInterceptor

      public WebTemplateInterceptor(WebTemplateRegistry webTemplateRegistry)
  • Method Details

    • setPrefixingPathRegistry

      @Autowired public void setPrefixingPathRegistry(PrefixingPathRegistry prefixingPathRegistry)
    • preHandle

      public boolean preHandle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler)
      Specified by:
      preHandle in interface org.springframework.web.servlet.HandlerInterceptor
    • postHandle

      public void postHandle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler, org.springframework.web.servlet.ModelAndView modelAndView)
      Specified by:
      postHandle in interface org.springframework.web.servlet.HandlerInterceptor