请教一下JSP图片上传的问题

if (!item.isFormField()) //文件字段
                        {
                            String fileName = item.getName();
                            if (fileName != null) {                            
                                String uploadPah = request.getSession()
                                        .getServletContext()
                                        .getRealPath("img/Product");
                                
                                code="Product"+(new java.util.Date().getTime()+""+(i++)+"");
                                
                                if(code!=null)
                                {
                                    File saveFile = new File(uploadPah,
                                            code+".jpg");
                                    item.write(saveFile);
                                    if(m.getImage()==null||m.getImage()==""){
                                        m.setImage(code+".jpg");                                        
                                    }else if(m.getImage2()==null||m.getImage2()==""){
                                        m.setImage2(code+".jpg");                                    
                                    }else{
                                        m.setImage3(code+".jpg");                                    
                                    }
                                    
                                }
                            
                            }
                        }

请问怎么判断,如果我在界面没有选择图片的时候提交表单让code不会生成?

And_I
浏览 1259回答 1
1回答

And_I

此贴终结!我知道了
打开App,查看更多内容
随时随地看视频慕课网APP