model.addattribute does not rendering the java object

classic Classic list List threaded Threaded
3 messages Options
uma
Reply | Threaded
Open this post in threaded view
|

model.addattribute does not rendering the java object

uma
I am trying to set a value in the model.addattribute

@GetMapping("/summary")
public String getSummaryScreen(Model model) {      
   Application application= getApplicationData();
   ClientValidationModel clientValidationModelView = getclientModel();      
    model.addAttribute("clientValidationModelView",clientValidationModelView);
   model.addAttribute("application","This my application");
   return "summary";
}

But if i try to access the application in the html file, the values is not rendered all the see on html output is
org.thymeleaf.context.WebEngineContext$ServletContextAttributesMap@18b8cee8

My HTML  is
<p th:text="${application}">applicationNumber</p>
Reply | Threaded
Open this post in threaded view
|

Re: model.addattribute does not rendering the java object

mkobel
The name application is already used by thymeleaf:

https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#web-context-namespaces-for-requestsession-attributes-etc.

This applies to param and session too.

Therefore I suggest to use a different name for your attribute.
uma
Reply | Threaded
Open this post in threaded view
|

Re: model.addattribute does not rendering the java object

uma
Thanks. I got that and changed the variable and now it works.