- All Superinterfaces:
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 TypeMethodDescriptiondefault JStachio
jstachio()
Returns the jstachio singleton by default.default Object
model()
The model to be rendered byjstachio()
.static JStachioModelView
Creates a spring view from a model with content type: "text/html; charset=utf-8
".static JStachioModelView
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 interfaceorg.springframework.web.servlet.View
- Throws:
Exception
-
jstachio
Returns the jstachio singleton by default.- Returns:
- stachio singleton by default.
- See Also:
-
model
The model to be rendered byjstachio()
.- Returns:
- model defaulting to
this
instance.
-
of
Creates a spring view from a model with content type: "text/html; charset=utf-8
".- Parameters:
model
- an instance of a class annotated withJStache
.- Returns:
- view ready for rendering
-
of
Creates a spring view from a model.- Parameters:
model
- an instance of a class annotated withJStache
.contentType
- SeeView.getContentType()
- Returns:
- view ready for rendering
-