-
-
Notifications
You must be signed in to change notification settings - Fork 202
Closed
Description
I have an endpoint like
@GET
@Path("/")
public MapModelAndView render() {
return new MapModelAndView("serp/first.jte")
.put("navbar", NavbarModel.SEARCH) // NavbarModel type
.put("websiteUrl", websiteUrl); // WebsiteUrl type
}and a JTE template expecting parameters like
@param NavbarModel navbar
@param WebsiteUrl websiteUrlWith jooby-jte as it is right now, this gives me an error
Server Error
message: Failed to render serp/first.jte, type mismatch for parameter: Expected nu.marginalia.search.model.NavbarModel, got java.util.HashMap
status code: 500
However, if I alter the sources at
| var mapModel = new HashMap<>(); |
from
var mapModel = new HashMap<>();to
var mapModel = new HashMap<String, Object>();It works as expected and renders the template.
JTE's TemplateEngine has two overloaded methods
public void render(String name, Object param, TemplateOutput output) throws TemplateException // ...
public void render(String name, Map<String, Object> params, TemplateOutput output) // ..I'm a bit surprised type erasure doesn't make it pick the second method with the code as it is, but it seems to go for the Object method (which passes the entire map as the parameter, rather than unpacking it).
I'm having the issue on JDK23 if that's maybe a factor.