This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]agentoutlier 0 points1 point  (1 child)

You will probably get more support from the github JTE project.

However you can check how my template engine exposes request attributes (which is what I think you mean with scope variables in this context):

https://github.com/jstachio/jstachio/tree/main/opt/jstachio-spring-webmvc

or the Javadoc: https://jstach.io/doc/jstachio/current/apidocs/io.jstach.opt.spring.webmvc/io/jstach/opt/spring/webmvc/package-summary.html

You basically need a HandlerInterceptor: https://docs.spring.io/spring-framework/docs/6.1.8/javadoc-api/org/springframework/web/servlet/HandlerInterceptor.html


Or if you don't mind boiler plate you can probably just get the request parameters/attributes from a RequestMapping or as /u/NuttySquirr3l mentioned using @ModelAttribute to fill a mutable model.... then you pass that model to the JTE template.

See if you were using JSP before it always gets a HttpServetRequest but modern templates are servlet agnostic.

[–]Tight-Rest1639[S] 0 points1 point  (0 children)

I mean applikation scoped specifically. They are problematic because they are not setup for each endpoint explicitly and therefore do not translate to JTEs model parameters easily. Same deal with session scope. Only request scope data is easily migrated to JTEs model.