Home > Back-end >  The small white and big help!!!!!!!!!!
The small white and big help!!!!!!!!!!

Time:01-31

Protected void doPost (it request, HttpServletResponse response) throws ServletException, IOException {
//create SmartUpload object
SmartUpload su=new SmartUpload ();

//make the early
Su. The initialize (enclosing getServletConfig (), request, response);

//upload process
Try {
Su. Upload ();
} the catch (SmartUploadException e) {
//TODO Auto - generated the catch block,
e.printStackTrace();
}

//access to upload the file object
Files fs=su. GetFiles ();
The File f=fs. GetFile (0);
//access to upload the file name
String fname=f.g etFileName ();

Try {
Su. Save (" images/product ");
} the catch (SmartUploadException e) {
//TODO Auto - generated the catch block,
e.printStackTrace();
}

Request req1=su. GetRequest ();

String pname=req1. GetParameter (" productName ");
String id=req1. GetParameter (" parentId ");
String price=req1. GetParameter (" productPrice ");
String desc=req1. GetParameter (" productDesc ");
String stock=req1. GetParameter (" productStock ");

FAMILY_PRODUCT p=new FAMILY_PRODUCT (
0,
Pname,
Desc,
Integer. The parseInt (price),
Integer. The parseInt (stock),
Integer. ParseInt (id. The split (" - ") [0]),
Integer. ParseInt (id. The split (" - ") [1]),
Fname
);

Int count=FAMILY_PRODUCTDao. Insert (p);

//where success or failure is redirected to the

If (count & gt; 0 {

Admin_productselect response. SendRedirect (" ");
} else {
PrintWriter out=response. GetWriter ();

Out. Write (" & lt; Script>" );
Out. Write (" alert (' goods add failure ') ");
Out. Write (" location. Href='https://bbs.csdn.net/topics/Manage/admin_toproductadd' ");
Out. Write (" & lt;/script>" );

}


}

}




The console error: Java. Lang. A NumberFormatException: null
The at Java. Lang. Integer. ParseInt (Unknown Source)
The at Java. Lang. Integer. ParseInt (Unknown Source)
At family. Servlet. Cate. DoUserCate. DoPost (DoUserCate. Java: 27)
The at javax.mail. Servlet. HTTP. HttpServlet. Service (HttpServlet. Java: 647)
The at javax.mail. Servlet. HTTP. HttpServlet. Service (HttpServlet. Java: 728)
The at org. Apache. Catalina. Core. ApplicationFilterChain. InternalDoFilter (ApplicationFilterChain. Java: 303)
The at org. Apache. Catalina. Core. ApplicationFilterChain. DoFilter (ApplicationFilterChain. Java: 208)
At org, apache tomcat, websocket server WsFilter. DoFilter (WsFilter. Java: 52)
The at org. Apache. Catalina. Core. ApplicationFilterChain. InternalDoFilter (ApplicationFilterChain. Java: 241)
The at org. Apache. Catalina. Core. ApplicationFilterChain. DoFilter (ApplicationFilterChain. Java: 208)
At family. Filter. AdminLogin. DoFilter (AdminLogin. Java: 60)
The at org. Apache. Catalina. Core. ApplicationFilterChain. InternalDoFilter (ApplicationFilterChain. Java: 241)
The at org. Apache. Catalina. Core. ApplicationFilterChain. DoFilter (ApplicationFilterChain. Java: 208)
The at org. Apache. Catalina. Core. StandardWrapperValve. Invoke (StandardWrapperValve. Java: 219)
The at org. Apache. Catalina. Core. StandardContextValve. Invoke (StandardContextValve. Java: 110)
The at org. Apache. Catalina. The authenticator. AuthenticatorBase. Invoke (AuthenticatorBase. Java: 444)
The at org. Apache. Catalina. Core. StandardHostValve. Invoke (StandardHostValve. Java: 169)
The at org. Apache. Catalina. Valves. ErrorReportValve. Invoke (ErrorReportValve. Java: 104)
The at org. Apache. Catalina. Valves. AccessLogValve. Invoke (AccessLogValve. Java: 1025)
The at org. Apache. Catalina. Core. StandardEngineValve. Invoke (StandardEngineValve. Java: 116)
At org. Apache. Catalina. Connector. CoyoteAdapter. Service (445) CoyoteAdapter. Java:
The at org. Apache. Coyote. Http11. AbstractHttp11Processor. Process (AbstractHttp11Processor. Java: 1137)
The at org. Apache. Coyote. AbstractProtocol $AbstractConnectionHandler. Process (AbstractProtocol. Java: 637)
At org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run JIoEndpoint. Java: (319)
The at Java. Util. Concurrent. ThreadPoolExecutor. RunWorker (Unknown Source)
The at Java. Util. Concurrent. ThreadPoolExecutor $Worker. The run (Unknown Source)
At org, apache tomcat. Util. Threads. TaskThread $WrappingRunnable. Run (61) TaskThread. Java:
The at Java. Lang. Thread. The run (Unknown Source)

CodePudding user response:

Parameter type conversion fails, you can put a few output to see into the int type, price, stock, id. The split (" - ") [0], id. The split (" - ") [1],

CodePudding user response:

I in front of the access to the file name fname seems to be an error, knowledge too shallow also don't know how to change
  • Related