Interface JStachioModelView

All Superinterfaces:
org.springframework.web.servlet.View

public interface JStachioModelView extends org.springframework.web.servlet.View
Another way to use JStachio with Spring MVC is to have models implement Springs View interface. You can enforce that your models implement this interface with JStacheInterfaces.

The model will use the static jstachio singleton that will be the spring one.

This approach has pros and cons. It makes your models slightly coupled to Spring MVC but allows you to return different views if say you had to redirect on some inputs (RedirectView).

Author:
agentgt
  • Field Summary

    Fields inherited from interface org.springframework.web.servlet.View

    PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE
  • Method Summary

    Modifier and Type
    Method
    Description
    default JStachio
    Returns the jstachio singleton by default.
    default Object
    The model to be rendered by jstachio().
    of(Object model)
    Creates a spring view from a model with content type: "text/html; charset=utf-8".
    of(Object model, String contentType)
    Creates a spring view from a model.
    default void
    render(Map<String,?> model, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
     

    Methods inherited from interface org.springframework.web.servlet.View

    getContentType
  • Method Details

    • render

      default void render(Map<String,?> model, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws Exception
      Specified by:
      render in interface org.springframework.web.servlet.View
      Throws:
      Exception
    • jstachio

      default JStachio jstachio()
      Returns the jstachio singleton by default.
      Returns:
      stachio singleton by default.
      See Also:
    • model

      default Object model()
      The model to be rendered by jstachio().
      Returns:
      model defaulting to this instance.
    • of

      static JStachioModelView of(Object model)
      Creates a spring view from a model with content type: "text/html; charset=utf-8".
      Parameters:
      model - an instance of a class annotated with JStache.
      Returns:
      view ready for rendering
    • of

      static JStachioModelView of(Object model, String contentType)
      Creates a spring view from a model.
      Parameters:
      model - an instance of a class annotated with JStache.
      contentType - See View.getContentType()
      Returns:
      view ready for rendering