Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service()java.lang.NumberFormatException:null_Hibernate_Jsp_Servlets_Model View Controller_Numberformatexception - Fatal编程技术网

Hibernate org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service()java.lang.NumberFormatException:null

Hibernate org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service()java.lang.NumberFormatException:null,hibernate,jsp,servlets,model-view-controller,numberformatexception,Hibernate,Jsp,Servlets,Model View Controller,Numberformatexception,我正在尝试更新我在电子商务商店中的一个产品的信息我正在使用JSP servlet和hibernate我使用(IDP)获得了该产品的详细信息,正如您在所附图片中看到的,我在IDP中添加了Integer.parseInt(int IDP=Integer.parseInt(request.getParameter(“IDP”);)但我仍然得到了NumberFormatException,如果代码出错,有人可以查看代码: 更新表单 <% Session s = HibernateUtil.get

我正在尝试更新我在电子商务商店中的一个产品的信息我正在使用JSP servlet和hibernate我使用(IDP)获得了该产品的详细信息,正如您在所附图片中看到的,我在IDP中添加了Integer.parseInt(int IDP=Integer.parseInt(request.getParameter(“IDP”);)但我仍然得到了NumberFormatException,如果代码出错,有人可以查看代码: 更新表单

 <% Session s = HibernateUtil.getSession();
            int idp = Integer.parseInt(request.getParameter("idp"));
            Produit p = (Produit) s.get(Produit.class, idp);

        %>
        <form class="was-validated" action="/Store/ModifProduit" method="post" enctype="multipart/form-data">
            
            <div class="form-group">
                <label for="validationTextarea" class="control-label">Idp</label>
                <input type="text" disabled="" class="form-control" value="<%=p.getIdp()%>">
                <input type="hidden" name="idp" value="<%=p.getIdp()%>" class="form-control">
            </div>
            
            <div class="form-group">
                <label for="validationTextarea" class="control-label">Libelle</label>
                <input type="text" name="libelle" required="" class="form-control" value="<%=p.getLibelle()%>">
            </div>

            <div class="form-group">
                <label for="validationTextarea">Marque</label>
                <input type="text" name="marque" required="" class="form-control" value="<%=p.getMarque()%>">
            </div>

            <div class="mb-3">
                <label for="validationTextarea">Prix</label>
                <input type="text" name="prix" required="" class="form-control" value="<%=p.getPrix()%>">
            </div>

            <div class="mb-3">
                <label for="validationTextarea">Frais d'expedition</label>
                <input type="text" name="frais" required="" class="form-control" value="<%=p.getFraisexpedition()%>">
            </div>

            <div class="mb-3">
                <label for="validationTextarea">Description</label>
                <textarea class="form-control is-invalid" name="description" id="validationTextarea" placeholder="Required example textarea" required><%=p.getDescription()%></textarea>
                <div class="invalid-feedback">
                    Please enter a message in the textarea.
                </div>
            </div>

            <div class="custom-control custom-checkbox mb-3">
                <input type="checkbox" class="custom-control-input" name="disponible">
                <label class="custom-control-label" for="customControlValidation1">Disponible</label>

            </div>

            <div class="mb-3">
                <label for="validationTextarea">Quantite en stock</label>
                <input type="text" name="qte" required="" class="form-control" value="<%=p.getQtestck()%>">
            </div>




            <div class="mb-3">
                <select class="custom-select" required name="cat">
                    <option value="">Choisir une categorie...</option>
                    <%                           
                        List<Categorie> cats = s.createQuery("From Categorie").list();
                        for (Categorie c : cats) {
                    %>
                    <option value="<%=c.getIdcat()%>"><%=c.getLibelle()%></option>
                    <%}%>
                </select>

            </div>

            <div class="custom-file mb-3">
                <input type="file" class="form-control" name="img1" id="validatedCustomFile" value="<%=p.getImages().get(0).getUrl()%>" required>
                <label class="custom-file-label" for="validatedCustomFile">Choisir l'image principale de votre produit...</label>

            </div>





            <div class="input-group is-invalid">
                <div class="custom-file">
                    <input type="file" class="custom-file-input" id="validatedInputGroupCustomFile" name="img2" value="<%=p.getImages().get(0).getUrl2()%>">
                    <label class="custom-file-label" for="validatedInputGroupCustomFile">Choisir Image2 (faculatif)...</label>
                </div>

                <div class="input-group-append">
                    <button class="btn btn-outline-secondary" type="submit">Sauvgarder</button>
                </div>
            </div>

        </form>
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    int idp=Integer.parseInt(request.getParameter("idp"));
    String libelle = request.getParameter("libelle");
    String description = request.getParameter("description");
    String marque = request.getParameter("marque");
    int prix = Integer.parseInt(request.getParameter("prix"));
    long idcat = Long.parseLong(request.getParameter("cat"));
    int frais = Integer.parseInt(request.getParameter("frais"));
    int qte = Integer.parseInt(request.getParameter("qte"));
    boolean disponible = false;
    if (request.getParameter("disponible") != null) {
        disponible = true;
    }
    Part p1 = request.getPart("img1");
    Part p2 = request.getPart("img2");

    String filename = p1.getHeader("content-disposition");
    String filename2 = p2.getHeader("content-disposition");

    for (String s : filename.split(";")) {
        if (s.trim().startsWith("filename")) {
            filename = s.substring(s.indexOf("=") + 1).trim().replace("\"", "");
            filename = filename.substring(filename.lastIndexOf('/') + 1).substring(filename.lastIndexOf('\\') + 1);
        }
    }
    for (String s : filename2.split(";")) {
        if (s.trim().startsWith("filename")) {
            filename2 = s.substring(s.indexOf("=") + 1).trim().replace("\"", "");
            filename2 = filename2.substring(filename2.lastIndexOf('/') + 1).substring(filename2.lastIndexOf('\\') + 1);
        }
    }
    p1.write(getServletContext().getRealPath("/images/product/" + filename));
    p2.write(getServletContext().getRealPath("/images/product/" + filename2));
    Session s = HibernateUtil.getSession();
    Produit p = (Produit) s.get(Produit.class, idp);
    s.beginTransaction();
    Categorie cat = (Categorie) s.get(Categorie.class, idcat);
    List<Image> images = new ArrayList<Image>();
    
    p.setIdp(0);
    p.setCategorie(cat);
    p.setDatePub(new Date());
    p.setDescription(description);
    p.setDisponibilite(disponible);
    p.setFraisexpedition(frais);
    p.setLibelle(libelle);
    p.setMarque(marque);
    p.setPrix(prix);
    p.setQtestck(qte);
    p.setImages(images);
    p.setCommentaires(null);
    p.setPromotions(null);
    p.setLignecommandes(null);
    p.setWishlists(null);
    Image img1 = new Image(0, p, filename, filename2, true);
    images.add(img1);

    s.save(img1);
    s.save(p);
    s.getTransaction().commit();
    request.setAttribute("msg", "Produit Modifier avec succes.");
    request.getRequestDispatcher("/views/formModifProduit.jsp").forward(request, response);
}
org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [ModifProduit] in context with path [/Store] threw exception
java.lang.NumberFormatException: null