Good evenning i no longer have a solution ..Ive been hesitating to ask for help but Im litteraly at a dead end . Im working on a Spring boot 2.0.5 Spring MVC 5.0.9, ThymeLeaf 3.0.9 project that needs to be delievered in few weeks ..I have encountered a problem for some weeks now ...did my research and tried every possible solution and I still have the same problem . In Fact, my controller does not bind my model variables to my view ...it always renders "EL1007E: Property or field 'fieldName' cannot be found on null" .. Ive litteraly tried everything(since my code is just fine )..
- upgrading and downgrading JDK/JRE and matching them with eclipse version worked once,got me the information i needed but then got the same issue back .
Using ModelAndView instead of String for rendreding web pages
mvn clean/mvn install /mvn dependency:resolve ...every command i found helpfull
- deleting the ./m2 repository for unnecessary dependencies
- even setting a new workspace ..compiling debugging and im really stuck .. can you give me some advice please !!
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
data-layout-decorate="~{index}">
<head>
<meta charset="UTF-8" />
<title>Page test</title>
</head>
<body>
<div data-layout-fragment="content">
<div class="container">
<div class="row">
<div class="col-sm-6" align="center">
<form th:action="@{/consulter}" method="get"
th:object="${paramSociete}">
<input type="text" name="nomSociete" class="form-control"
placeholder="AMEN BANK" />
<button type="submit">Clique moi !!</button>
</form>
<br /> <br /> <br /> <br />
<div>
<div>
<label>Nom Banque :</label><Label th:inline="text">
[[${paramSociete.nomSociete}]]</Label>
</div>
<div>
<label>Reference msg:</Label><Label th:inline="text">[[${paramSociete.initialMsg}]]</Label>
</div>
<div>
<label>chemin dacces:</label> <Label th:inline="text">[[${paramSociete.pathMsgEmis}]]</Label>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
@Controller
public class ParamSocieteController {
@Autowired
private ParamSocieteServiceImpl societeServiceImpl;
@Autowired
public void setSocieteServiceImpl(ParamSocieteServiceImpl societeServiceImpl) {
this.societeServiceImpl = societeServiceImpl;
}
@RequestMapping(value="/")
public String showTest() {
System.out.println("Here we go !!");
return "ThymeTest";
}
@RequestMapping(value = "/consulter")
public String afficherAmenBank(Model model, String nomSociete) {
ParamSociete societe = societeServiceImpl.findSociete(nomSociete);
if (societe == null) {
model.addAttribute("paramSociete", new ParamSociete());
} else {
model.addAttribute("nomSociete", nomSociete);
model.addAttribute("paramSociete", societe);
System.out.println(societe.getNomSociete());
System.out.println(societeServiceImpl.findSociete(societe.getNomSociete()).toString());
}
return "ThymeTest";
}
}
so i did nothing in my controller but did this in my view : I tested if my object existed with th:if
<div th:if="${paramSociete}">
<div>
<label>Nom Banque :</label><Label th:inline="text">
[[${paramSociete.nomSociete}]]</Label>
</div>
<div>
<label>Reference msg:</Label><Label th:inline="text">[[${paramSociete.initialMsg}]]</Label>
</div>
<div>
<label>chemin dacces:</label> <Label th:inline="text">[[${paramSociete.pathMsgEmis}]]</Label>
</div>
</div>