I am newbie to Jtwig, well I am facing an issue while creating Jtwig template that I am having interceptor class that is passing request attribute request.setAttribute("name","spring");
to the template and my jtwig template is not processing the HttpServletRequest attribute.
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
request.setAttribute("name", "Springs");
modelAndView.setViewName("index");
} else {
modelAndView.setViewName("404");
}
}
my .twig file
<html>
<head>
<title>Hello world</title>
</head>
<body>
<h1>Hello world! {{ name }}</h1>
</body>
</html>
can anyone tell me what causing this error ?
If you need to add the attributes to the model, try this:
modelAndView.getModelMap().addAttribute("key", "value")