Error: Object Property is Null

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

Error: Object Property is Null

apprentice
I am getting a null pointer on one of the model properties.  When I try to access the 'image' property (see model) with th:src e.g. "< img th:src="${account.image.directory}" / >" i get a complaint saying 'image' property is null.  


Model Object

public class Account{
  private Image image;
  private int id;
  ....
//getters and settters
}


The following is an extract from template.  

<form  th:accept-charset="UTF-8" th:object="${account}" th:action="@{/id=${account.id}" enctype="multipart/form-data" method="post">
< img th:src="${account.image.directory}+'/'+${account.image.name}" th:alt="${account.image.name}" / >
</form>
Reply | Threaded
Open this post in threaded view
|

Re: Error: Object Property is Null

Zemi
Administrator
Hello,

the simplest explanation is that your image property is null. Please double check that, for example, you can print it with
    <span th:text="${account.image}"></span>

Regards,
   Zemi

Reply | Threaded
Open this post in threaded view
|

Re: Error: Object Property is Null

apprentice
Thanks