My project based on spring boot,Thymeleaf,mysql,html and Jquery.
My scenario is to Get the List iterate and show the d
You used the form at the top of your html page:
<form method="post" th:object="${entSetCharges}" th:action="@{/updatesetcharges}">
The th:field="*{chargesName}
is bound to the object/bean inside your th:object="${entSetCharges}
. Meaning that you are searching for a chargesName
field inside your entSetCharges
object which does not exist or is null.
Solution:
Maybe change your th:field="*{chargesName}"
to ${savedcharges.chargesName}
expression to access your object's field.
Try adding respondResult.addObject("entSetCharges",new EntSetCharges());
above your return line. Your view doesn't automatically create this object for you.
I init the entity object like respondResult.addObject("entSetCharges",new EntSetCharges());
@GetMapping(value="/setchargeslist")
public ModelAndView doGetSetchargesList()
{
List<EntSetCharges> listCharges = new ArrayList<>();
ModelAndView respondResult = new ModelAndView("SetCharges");
try {
/*Get the set charges list*/
listCharges = serSetCharges.doGetSetChargesList();
if(listCharges!=null)
{
respondResult.addObject("savedchargeslist",listCharges);
respondResult.addObject("entSetCharges",new EntSetCharges());
}
else
{
respondResult.addObject("savedchargeslist",new ArrayList<>());
}
} catch (Exception e) {
// TODO: handle exception
}
return respondResult;
}