2020年12月22日星期二

Could not show Data on my view : Exception evaluating SpringEL expression

I'm creating a bankin application using Spring boot and thymeleaf, I face the following error when I try to show the data of an account: Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "compte.codeCompte" (template: "comptes" - line 34, col 14)

Here is my bankController:

import java.util.Arrays;  import java.util.Date;  import java.util.List;        import org.springframework.beans.factory.annotation.Autowired;      import org.springframework.stereotype.Controller;      import org.springframework.ui.Model;      import org.springframework.web.bind.annotation.GetMapping;      import org.springframework.web.bind.annotation.RequestMapping;      import org.springframework.web.bind.annotation.ResponseBody;      import org.springframework.web.bind.annotation.RestController;            import com.projets.bank.entities.Client;      import com.projets.bank.entities.Compte;      import com.projets.bank.entities.CompteEpargne;      import com.projets.bank.metier.ServiceLayer;            @Controller                  public class BankController       {          @Autowired          private ServiceLayer banque;                @RequestMapping("/operation")                public String index()          {              return "comptes";          }                    @RequestMapping("/consulterCompte")          public String consulterCompte(Model model, String codeCompte)          {              try              {                  Compte cp = banque.consulterCompte(codeCompte);                  model.addAttribute("compte",cp);              }              catch(Exception e)              {                  model.addAttribute("exception", e);              }              return "comptes";                }                            }  

comptes.html:

<div class="card-body">                      <div>                          <label>Code: </label>                          <label th:text="${compte.codeCompte}">Code: </label>                      </div>                      <div>                          <label>Solde: </label>                          <label th:text="${compte.solde}"> </label>                      </div>                      <div>                          <label>Date de création: </label>                          <label th:text="${compte.dateCreation}"> </label>                      </div>                      <div>                          <label>Type: </label>                          <label th:text="${compte.class.simpleName}"> </label>                      </div>                  </div>  

Compte.java:

public abstract class Compte implements Serializable {        /**       *        */      private static final long serialVersionUID = 1L;      @Id      private String codeCompte;            private Date dateCreation;      private double solde;            @ManyToOne      @JoinColumn(name="CODE_CLI")      private Client client;            @OneToMany(mappedBy="compte" )      private Collection<Operation> operation;            public Compte() {          super();      }      public Compte(String codeCompte, Date dateCreation, double solde, Client client) {          super();          this.codeCompte = codeCompte;          this.dateCreation = dateCreation;          this.solde = solde;          this.client = client;      }      public String getCodeCompte() {          return codeCompte;      }      public void setCodeCompte(String codeCompte) {          this.codeCompte = codeCompte;      }      public Date getDateCreation() {          return dateCreation;      }      public void setDateCreation(Date dateCreation) {          this.dateCreation = dateCreation;      }      public double getSolde() {          return solde;      }      public void setSolde(double solde) {          this.solde = solde;      }      public Client getClient() {          return client;      }      public void setClient(Client client) {          this.client = client;      }      public Collection<Operation> getOperation() {          return operation;      }      public void setOperation(Collection<Operation> operation) {          this.operation = operation;      }                    }  

Thanks in advance.

https://stackoverflow.com/questions/65416929/could-not-show-data-on-my-view-exception-evaluating-springel-expression December 23, 2020 at 06:58AM

没有评论:

发表评论