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

Servlets/JSP Java Discussion :

Impossible d'afficher les données la base MySQL


Sujet :

Servlets/JSP Java

  1. #1
    Membre régulier
    Homme Profil pro
    Développeur Web
    Inscrit en
    Décembre 2013
    Messages
    205
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2013
    Messages : 205
    Points : 102
    Points
    102
    Par défaut Impossible d'afficher les données la base MySQL
    Bonsoir,
    Je suis débutant et pour mon exercice je travaille sur un projet de gestion de produits.
    Mais voilà, je n'arrive pas à afficher les données de la base MySQL. J'ai comme serveur Tomcat 10.1.
    La page s'affiche mais aucune donnée.

    Fichier JSP

    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
    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    	<h1>LISTE DES PRODUITS</h1>
    	<table border="1">
    		<tr>
    			<th>DESIGNATION</th>
    			<th>PRIX</th>
    			<th>POIDS</th>
    			<th>DATE PEREMPTION</th>
    		</tr>
    		<c:forEach var="produit" items="${produits}">
    		<tr>
    			<td><c:out value="${produit.designation}" /></td>
    			<td><c:out value="${produit.prix}" /></td>
    			<td><c:out value="${produit.poids}" /></td>
    			<td><c:out value="${produit.date}" /></td>
    		</tr>	
    		</c:forEach>
    	</table>
    </body>
    </html>
    Code de connexion à la base
    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
    public class Singleton {
    	private static Connection connection;
     
    	static {
    		try {
    			Class.forName("com.mysql.jdbc.Driver");
     
    			connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/gestionproduit", "root","");
    		}
    		catch(SQLException | ClassNotFoundException e) {
    			e.printStackTrace();
    		}
    	}
     
    	public static Connection getConnection() {
    		return connection;
    	}
     
    }
    Mon fichier bean Produit
    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
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    public class ProduitBean {
    	private int id;
    	private String designation ;
    	private Double prix;
    	private Double poids;
    	private String datePeremption;
     
    	public ProduitBean() {
    		super();
    	}
     
    	public ProduitBean(String designation, Double prix, Double poids, String dateperemption) {
    		this.designation = designation;
    		this.prix = prix;
    		this.poids = poids;
    		this.datePeremption = dateperemption;
    	}
     
    	public int getId() {
    		return id;
    	}
     
    	public void setId(int id) {
    		this.id = id;
    	}
     
    	public String getDesignation() {
    		return designation;
    	}
     
    	public void setDesignation(String designation) {
    		this.designation = designation;
    	}
     
    	public Double getPrix() {
    		return prix;
    	}
     
    	public void setPrix(Double prix) {
    		this.prix = prix;
    	}
     
    	public Double getPoids() {
    		return poids;
    	}
     
    	public void setPoids(Double poids) {
    		this.poids = (double) poids;
    	}
     
    	public String getDatePeremption() {
    		return datePeremption;
    	}
     
    	public void setDatePeremption(String date) {
    		this.datePeremption = date;
    	}
    }
    Fichier Produit qui implémente l'interface Produit

    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
    33
    34
    35
    36
    37
    public class C_Produit implements I_Produit{
     
    	Connection cn = null;
    	PreparedStatement ps = null;
    	ResultSet rs = null;
     
    	public List<ProduitBean> getListeProduit() {
    		List<ProduitBean> produits = new ArrayList<ProduitBean>();
    		try {
     
    			cn = Singleton.getConnection();
    			ps = cn.prepareStatement("SELECT * FROM produit");
    			rs = ps.executeQuery();
     
    			while(rs.next()) {
     
    				String designation = rs.getString("designation");
    				Double prix = rs.getDouble("prix");
    				Double poids = rs.getDouble("poids");
    				String date = rs.getString("date");
     
    				ProduitBean ListProduit = new ProduitBean();
    				ListProduit.setDesignation(designation);
    				ListProduit.setPrix(prix);
    				ListProduit.setPoids(poids);
    				ListProduit.setDatePeremption(date);
     
    				produits.add(ListProduit);
    			}
    		}
    		catch(SQLException e) {
    			e.printStackTrace();
    		}
     
    		return produits;
    	}
    }
    Ma Servlet

    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
    @WebServlet("/ProduitServlet")
    public class ProduitServlet extends HttpServlet {
    	private static final long serialVersionUID = 1L;
     
        public ProduitServlet() {
        	super();
        }
     
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        	C_Produit listProduit = new C_Produit();
        	request.setAttribute("produits", listProduit.getListeProduit());
     
            this.getServletContext().getRequestDispatcher( "/liste.jsp" ).forward( request, response );
        }
     
     
        protected void doPost(HttpServletRequest request, ServletResponse response) throws ServletException, IOException {
       }
    }
    Fichier web.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
      <display-name>ProduitServlet</display-name>
     
    <servlet>
       <servlet-name>ProduitServlet</servlet-name>
       <servlet-class>com.controler.ProduitServlet</servlet-class>
    </servlet>
    <servlet-mapping> 
       <servlet-name>ProduitServlet</servlet-name>
       <url-pattern>/liste</url-pattern>
    </servlet-mapping>
    </web-app>

  2. #2
    Membre éprouvé

    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    476
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2009
    Messages : 476
    Points : 925
    Points
    925
    Billets dans le blog
    5
    Par défaut
    Bonjour,

    Pour commencer, il serait souhaitable d'utiliser des conventions de nommage adéquates, c'est à dire celles que l'on utilise en Java.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    public class C_Produit implements I_Produit{
    Doit être remplacé par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    public class ProduitDAOImpl implements ProduitDAO{
    Vu que public C_Produit a le rôle d'une DAO.

    De même, je ne recommande pas d'utiliser le singleton "pure java". C'est un antipattern.

    Pour ma part, je recommande l'injection de dépendance, qui se fait par un framework comme Spring/EJB/CDI...

    Les données de la BDD sont donc dans une interface (Attention, dans mon projet, j'utilise une convention un peu particulière):
    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
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
     
    package com.calculateur.warhammer.base.server;
     
    /**
     * Interface pour la configuration en BDD
     * @author phili
     *
     */
    public interface IDatabaseConfiguration {
     
    	/**
    	 * 
    	 * @return URL
    	 */
    	String getUrl();
     
    	/**
    	 * 
    	 * @return URL JDBC
    	 */
    	String getJDBCUrl();
     
    	/**
    	 * 
    	 * @return User
    	 */
    	String getUser();
     
    	/**
    	 * 
    	 * @return Password
    	 */
    	String getPassword();
     
    	/**
    	 * 
    	 * @return port
    	 */
    	String getPort();
     
    	/**
    	 * 
    	 * @return Le Driver JDBC
    	 */
    	String getClassDriver();
     
    	/**
    	 * 
    	 * @return Un String donnant les informations de la BDD
    	 */
    	String getInformations();
    }
    Comme ça, quand j'utilise du pur JDBC...
    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
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
     
    package com.calculateur.warhammer.create.database.sql;
     
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import java.util.Map;
    import java.util.Map.Entry;
    import java.util.TreeMap;
    import java.util.logging.Level;
    import java.util.logging.Logger;
     
    import com.calculateur.warhammer.base.bdd.IExecuteSQL;
    import com.calculateur.warhammer.base.exception.DAOException;
    import com.calculateur.warhammer.base.server.IDatabaseConfiguration;
     
    public class ExecuteFichiersSQL implements IExecuteSQL {
     
    	private static final Logger LOGGER = Logger.getLogger(ExecuteFichiersSQL.class.getName());
     
    	private static final String SEPARATOR_SQL_FILE = "_";
     
    	private static final String SQL_COMMENTAIRE = "--";
     
    	private static final int INDEX_NUMERO = 0;
     
    	private final File folderSQL;
     
    	private final IDatabaseConfiguration configuration;
     
    	private final Map<Integer, File> mapExecution;
     
    	public ExecuteFichiersSQL(File folderSQL, IDatabaseConfiguration configuration) {
    		this.folderSQL = folderSQL;
    		this.configuration = configuration;
    		mapExecution = new TreeMap<>();
    	}
     
    	@Override
    	public void executeSQL() throws DAOException {
    		try {
    			determinerOrdreExecution();
    			executeSQLFiles();
    		} catch (Exception e) {
    			throw new DAOException(e);
    		}
    	}
     
    	private void determinerOrdreExecution() {
    		String fileName;
    		String[] tab;
    		Integer order;
    		for (File sqlFile : folderSQL.listFiles()) {
    			fileName = sqlFile.getName();
    			tab = fileName.split(SEPARATOR_SQL_FILE);
    			order = Integer.parseInt(tab[INDEX_NUMERO]);
    			mapExecution.put(order, sqlFile);
    		}
    	}
     
    	private void executeSQLFiles() throws ClassNotFoundException, SQLException, IOException {
    		Class.forName(configuration.getClassDriver());
    		try (Connection connection = DriverManager.getConnection(configuration.getJDBCUrl(), configuration.getUser(),
    				configuration.getPassword())) {
    			for (Entry<Integer, File> entry : mapExecution.entrySet()) {
    				LOGGER.info("Execution ficnier n°" + entry.getKey() + " " + entry.getValue().getAbsolutePath());
    				executeSQLFile(connection, entry.getValue());
    				LOGGER.info("Le ficnier n°" + entry.getKey() + " " + entry.getValue().getAbsolutePath()+" a été executé entièrement");
    			}
    		}
    	}
     
    	private void executeSQLFile(Connection connection, File file) throws IOException, SQLException {
    		try (BufferedReader br = new BufferedReader(new FileReader(file))) {
    			String sql;
    			while ((sql = br.readLine()) != null) {
    				if(!sql.isEmpty() && !sql.startsWith(SQL_COMMENTAIRE)) {
    					executeUpdate(connection, sql);
    				}
    			}
    		}
    	}
     
    	private void executeUpdate(Connection connection,String sql)throws SQLException{
    		try(PreparedStatement ps =connection.prepareStatement(sql)){
    			LOGGER.log(Level.INFO,"Execute SQL : {0}",sql);
    			ps.executeUpdate();
    		}
    	}
    }
    De fait, la classe C_Produit (Mon dieu quel nom à vomir) prend en paramètre la configuration de la BDD dans le constructeur.

    Pour en revenir au Singleton (qui pour moi est en fait un anti-pattern), on devrait avoir:
    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
     
    public class MonSingleton{
     
       private static final MonSingleton INSTANCE;
     
       private MonSingleton(){
          //Important: Un constructeur privé, qui n'est utilisé que dans le getInstance().
       }   
     
       public static MonSingleton getInstance(){
           if(INSTANCE == null){
               INSTANCE = new MonSingleton();
           }
     
       }
     
    }
    Pour la DAO, je recommande d'être plus "con" dans le SQL utilisé.

    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
    33
    34
    35
    36
     
    public class C_Produit implements I_Produit{
     
           private static final String SQL = "SELECT * FROM produit";
     
    	public List<ProduitBean> getListeProduit() {
    		List<ProduitBean> produits = new ArrayList<ProduitBean>();
    		try(Connection cn = Singleton.getConnection(); PreparedStatement ps = cn.prepareStatement(SQL); ResultSet rs = ps.executeQuery()) {
     
    			cn = Singleton.getConnection();
    			ps = cn.prepareStatement("SELECT designation, prix, poids,d date FROM produit");
    			rs = ps.executeQuery();
     
    			while(rs.next()) {
     
    				String designation = rs.getString("designation");
    				Double prix = rs.getDouble("prix");
    				Double poids = rs.getDouble("poids");
    				String date = rs.getString("date");
     
    				ProduitBean ListProduit = new ProduitBean();
    				ListProduit.setDesignation(designation);
    				ListProduit.setPrix(prix);
    				ListProduit.setPoids(poids);
    				ListProduit.setDatePeremption(date);
     
    				produits.add(ListProduit);
    			}
    		}
    		catch(SQLException e) {
    			e.printStackTrace();
    		}
     
    		return produits;
    	}
    }
    Tout ce qui est Connexion/PreparedStatement/ResultSet est propre à la méthode, et ne doit être définie que dans la méthode. Notez que tout ça est autoclosable ( https://docs.oracle.com/javase/8/doc...Closeable.html ) et doit être fermé, le try-with-ressources étant la meilleure solution.

    Après, sur le reste (en dehors des problèmes de nommage/architecture/code...) me semble correcte. Il faudrait les messages d'erreur pour pouvoir plus t'aider.

  3. #3
    Membre régulier
    Homme Profil pro
    Développeur Web
    Inscrit en
    Décembre 2013
    Messages
    205
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2013
    Messages : 205
    Points : 102
    Points
    102
    Par défaut
    Bonjour PhilippeGibault,
    Merci pour tes remarques, le nommage a été fait.
    L'exercice s'inscrit dans le cadre d'apprentissage (formation). Je dois donc rester conforme à la procédure non utilisation de framework.
    Voila l'erreur qui s'affiche. Il s'agit d'un problème de connexion à MySql.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'performance_schema.session_variables' doesn't exist

  4. #4
    Membre éprouvé

    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    476
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2009
    Messages : 476
    Points : 925
    Points
    925
    Billets dans le blog
    5
    Par défaut
    Je crois que c'est ton serveur de BDD qui est pourri (ce qui d'ailleurs est une habitude pour MySQL):

    https://www.carnaghan.com/knowledge-...-doesnt-exist/

    https://www.developpez.net/forums/d2...ion_variables/


    https://stackoverflow.com/questions/...-session-varia


    https://stackoverflow.com/questions/...gogogo-chatmes


    https://stackoverflow.com/questions/...s-doesnt-exist

    ect...

    Le serveur étant KAPUT, il ne peut donc pas répondre correctement.

  5. #5
    Membre régulier
    Homme Profil pro
    Développeur Web
    Inscrit en
    Décembre 2013
    Messages
    205
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2013
    Messages : 205
    Points : 102
    Points
    102
    Par défaut
    Merci, j'ai opté pour le changement du serveur.
    J'arrive à afficher les donner dans la console mais pas sur la vue jsp.

    Servlet
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    @WebServlet("/ProduitServlet")
    public class ProduitServlet extends HttpServlet {
    	private static final long serialVersionUID = 1L;
     
    	public ProduitServlet() {
        	   super();
           }
     
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        	ProduitDAOImpl lsiteProduit = new ProduitDAOImpl();
        	request.setAttribute("produits", lsiteProduit);
        	this.getServletContext().getRequestDispatcher( "/liste.jsp" ).forward( request, response );
        }
    }
    ProduitDAOImpl

    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
    	public List<ProduitBean> getListeProduit() {
    		List<ProduitBean> produit = new ArrayList<ProduitBean>();
     
    		try{
     
    			Connection con = ConnexionDB.getConnection();
    			PreparedStatement ps = con.prepareStatement("SELECT * FROM produit");
    			ResultSet rs = ps.executeQuery();
     
    			while(rs.next()) {
     
    				String designation = rs.getString("designation");
    				Double prix = rs.getDouble("prix");
    				Double poids = rs.getDouble("poids");
    				Date datePeremption = rs.getDate("datePeremption");
     
    				ProduitBean ListProduit = new ProduitBean();
    				ListProduit.setDesignation(designation);
    				ListProduit.setPrix(prix);
    				ListProduit.setPoids(poids);
    				ListProduit.setDatePeremption(datePeremption);
     
    				produit.add(ListProduit);
    			}
    		}
    		catch(SQLException e) {
    			e.printStackTrace();
    		}
     
    		return produit;
    	}
    Vue JSP
    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
    <table border="1">
    		<tr>
    			<th>DESIGNATION</th>
    			<th>PRIX</th>
    			<th>POIDS</th>
    			<th>DATE PEREMPTION</th>
    		</tr>	
    		<c:forEach var="p" items="${ produits }">
    		<tr>
    			<td><c:out value="${ p.getDesignation }" /></td>
    			<td><c:out value="${ p.getPrix  }" /></td>
    			<td><c:out value="${ p.getPoids  }" /></td>
    			<td><c:out value="${ p.getDatePeremption  }" /></td>
    		</tr>	
    		</c:forEach>
    	</table>
    Résultat :
    Nom : Capture d’écran 2023-07-27 à 19.39.29.png
Affichages : 49
Taille : 21,6 Ko

    Lorsque je fais un test unitaire, les données s'affichent dans la console.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    public static void main(String[] args) {
    		ProduitDAOImpl metier = new ProduitDAOImpl();
    		List<ProduitBean> prods = metier.getListeProduit();
     
    		for(ProduitBean p:prods ) {
    			System.out.println(p.getDesignation());
    		}
     
    	}
    Nom : Capture d’écran 2023-07-27 à 19.37.23.png
Affichages : 47
Taille : 10,4 Ko

  6. #6
    Membre éprouvé

    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    476
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2009
    Messages : 476
    Points : 925
    Points
    925
    Billets dans le blog
    5
    Par défaut
    A mon avis, peut-être que:
    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
     
    <table border="1">
    		<tr>
    			<th>DESIGNATION</th>
    			<th>PRIX</th>
    			<th>POIDS</th>
    			<th>DATE PEREMPTION</th>
    		</tr>	
    		<c:forEach var="p" items="${ produits }">
    		<tr>
    			<td><c:out value="${ p.getDesignation }" /></td>
    			<td><c:out value="${ p.getPrix  }" /></td>
    			<td><c:out value="${ p.getPoids  }" /></td>
    			<td><c:out value="${ p.getDatePeremption  }" /></td>
    		</tr>	
    		</c:forEach>
    	</table>
    Se remplace par:

    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
     
    <table border="1">
    		<tr>
    			<th>DESIGNATION</th>
    			<th>PRIX</th>
    			<th>POIDS</th>
    			<th>DATE PEREMPTION</th>
    		</tr>	
    		<c:forEach var="p" items="${produits}">
    		<tr>
    			<td><c:out value="${p.getDesignation}" /></td>
    			<td><c:out value="${p.getPrix }" /></td>
    			<td><c:out value="${p.getPoids }" /></td>
    			<td><c:out value="${p.getDatePeremption }" /></td>
    		</tr>	
    		</c:forEach>
    	</table>
    Je ne pense pas qu'il y ait des espace dans JSTL.

    Après, on n'utilise plus beaucoup JSTL aujour d'hui...

Discussions similaires

  1. Réponses: 2
    Dernier message: 11/04/2019, 13h36
  2. [Python 2.X] Comment afficher les données enregistrer du MySQL sur un canvas du Tkinter
    Par universjord dans le forum Interfaçage autre langage
    Réponses: 1
    Dernier message: 20/09/2018, 18h38
  3. Réponses: 0
    Dernier message: 23/01/2012, 18h25
  4. Impossible d'afficher les données d'un clé USB
    Par willytito dans le forum Composants
    Réponses: 8
    Dernier message: 26/11/2009, 10h38
  5. Réponses: 1
    Dernier message: 31/07/2009, 08h12

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