IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Java Discussion :

Charger table de thymeleaf d'un controller


Sujet :

Spring Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Juin 2012
    Messages
    242
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2012
    Messages : 242
    Par défaut Charger table de thymeleaf d'un controller
    bonjour;

    je fait charger un table en thymeleaf par une methode de class controller mais toujours le table est vide et voiçi le code de classe controller et le fichier html :

    classe controller :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
     
    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.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
     
    import com.praogramme.test.domain.Produit;
    import com.praogramme.test.service.ProduitManager;
     
    @Controller
     
    public class ProduitController {
    	@Autowired
    	ProduitManager manager;
     
    	protected String page = "my";
     
     
     
     
     
     
        @RequestMapping(value = "message", method = RequestMethod.GET)
        public String messages(Model model) {
            model.addAttribute("messages",manager.listeDeProduits());
            return "my";
        }
     
    }
    ------------------------
    le fichier my.html


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    <html lang="en"
          xmlns="http://www.w3.org/1999/xhtml"
          xmlns:th="http://www.thymeleaf.org">
     
    <head>
        <title>Home</title>
    </head>
    <body>
     
     
    <table class="table table-striped">
                 <thead>
    			<tr>
    				<th>ID</th>
    				<th>Description</th>
    				<th>Prix</th>
     
    			</tr>
    		</thead>
     
          <tbody>  
          <tr th:each="contact : ${message}">  
            <td th:text="${contact.idProduit}"></td>  
            <td th:text="${contact.Desciption}"></td>  
            <td th:text="${contact.prix}"></td>
        </tr>  
        </tbody>
    </table>
    </body>
    </html>
    --------------------------

    je vais que quelqu'un m'aide pour ce code ou me donne un exemple bien détailler;

    et merci.

  2. #2
    Invité
    Invité(e)
    Par défaut
    Tu itères bien sur message's' ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <tr th:each="contact : ${messages}">

Discussions similaires

  1. comment charger la taille de texte pour control édit
    Par PIC16F877A dans le forum Windows
    Réponses: 1
    Dernier message: 21/10/2011, 10h25
  2. [VB6] Remplir et MAJ de tables Access 97 avec Data Control
    Par PrincessKC dans le forum VB 6 et antérieur
    Réponses: 9
    Dernier message: 25/03/2010, 19h05
  3. charger table ctl forms
    Par hichcasa dans le forum Forms
    Réponses: 0
    Dernier message: 06/04/2009, 14h12
  4. pb charger table type utilisateur > 64k
    Par PacoE dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 29/11/2008, 14h06
  5. Réponses: 2
    Dernier message: 26/04/2006, 15h14

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo