问题描述
org.apache.jasper.JasperException:AnexceptionoccurredprocessingJSPpage/merchant/goodsAddSave.jspatline2926:SmartUploadmyUpload=newSmartUpload();27:myUpload.initialize(pageContext);28:29:if(myUpload.getRequest().getParameter("isReUpload").equals("1")){30:31:myUpload.setAllowedFilesList("jpg,JPG");32:myUpload.upload();Stacktrace:org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rootcausejava.lang.NullPointerExceptionorg.apache.jsp.merchant.goodsAddSave_jsp._jspService(goodsAddSave_jsp.java:93)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)javax.servlet.http.HttpServlet.service(HttpServlet.java:803)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)javax.servlet.http.HttpServlet.service(HttpServlet.java:803)源代码goodsAddSave.jsp<%@pagelanguage="java"contentType="text/html;charset=gb2312"%><%@pageimport="java.sql.*,com.netshop.*,java.text.*,com.jspsmart.upload.*"%><HTML><HEAD><title>商品交易平台</title><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"><styletype="text/css"><!--body{background-color:#ADBACE;background-image:url(../images/login.jpg);}--></style></HEAD><BODY><jsp:useBeanid="goods"scope="page"class="com.netshop.goods"/><divalign=left><%StringstrTime;SimpleDateFormatdateFormatterfile=newSimpleDateFormat("yyyyMMddHHmmss");strTime=dateFormatterfile.format(newjava.util.Date());StringfileName="";SmartUploadmyUpload=newSmartUpload();myUpload.initialize(pageContext);if(myUpload.getRequest().getParameter("isReUpload").equals("1")){myUpload.setAllowedFilesList("jpg,JPG");myUpload.upload();fileName=strTime;myUpload.getFiles().getFile(0).saveAs("images/"+fileName);}if(myUpload.getRequest().getParameter("isReUpload").equals("1")){goods.goodsURL=fileName;}goods.title=myUpload.getRequest().getParameter("title");goods.description=myUpload.getRequest().getParameter("description");goods.goodsField=Integer.parseInt(myUpload.getRequest().getParameter("mainFields"));goods.price=Integer.parseInt(myUpload.getRequest().getParameter("price"));goods.linkMan=myUpload.getRequest().getParameter("linkMan");goods.telephone=myUpload.getRequest().getParameter("telephone");goods.issuer=((com.netshop.user)session.getAttribute("user")).ID;if(goods.add()){%><center><fontsize=5>商品发布成功!</font></center><br><br><center><inputtype=buttonname=gofirstvalue=确定onclick=javascript:window.location='myGoodsList.jsp'></center><%}else{%><center><fontcolor=redsize=5>商品发布失败,请重试!</font></center><br><br><center><inputtype=buttonname=gobackvalue=返回onclick=javascript:window.history.go(-1)></center><%}%></div></BODY></HTML><%@pagecontentType="text/html;charset=gb2312"language="java"%><%@pageimport="java.sql.*,com.netshop.*"%><%!publicStringcodeToString(Stringstr){Strings=str;try{bytetempB[]=s.getBytes("ISO-8859-1");s=newString(tempB);returns;}catch(Exceptione){returns;}}%><html><head><title>商品交易平台</title><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"><SCRIPTlanguage=javascript><!--functionisReUpload_onclick(){if(form1.isReUpload[0].checked)//不传{form1.file.disabled=true;}if(form1.isReUpload[1].checked)//上传{form1.file.value="";form1.file.disabled=false;}}//--></SCRIPT><styletype="text/css"><!--body{background-color:#ADBACE;background-image:url(../images/login.jpg);}--></style></head><jsp:useBeanscope="page"id="goodsField"class="com.netshop.goodsField"/><%StringstrGoodsID="";goodsField.init(strGoodsID);%><body><divalign="center"><FORMname="form1"onReset="returnconfirm('确定要清空当前表单吗?');"action=goodsAddSave.jspmethod=postenctype="multipart/form-data"><TABLEcellSpacing=1cellPadding=3width="90%"align=centerborder=0><TBODY><TR><TDalign=rightwidth="17%">商品名称:</TD><TDalign=leftwidth="83%"><inputtype="text"name="title"size="30"></TD></TR><TR><TDwidth="20%"align=rightvAlign=top>商品类别:</TD><TDwidth="80%"align=left><selectstyle="WIDTH:150px"id=mainFieldsname="mainFields"><%ResultSetrs=goodsField.showAllFields();while(rs.next()){%><optionvalue=<%=rs.getLong("ID")%>><%=codeToString(rs.getString("name"))%></option><%}%></select></TD></TR><TR><TDvAlign=topalign=right>商品介绍:</TD><TDalign=left><textareaname=descriptionrows=6id="descriptions"style="WIDTH:233px"></textarea></TD></TR><TR><TDvAlign=topalign=right>是否上传图片:</TD><TDalign=left><inputtype="radio"checked=truevalue=0name="isReUpload"LANGUAGE=javascriptonClick="returnisReUpload_onclick()">否<inputtype="radio"value=1name="isReUpload"LANGUAGE=javascriptonClick="returnisReUpload_onclick()">是</TD></TR><TR><TDvAlign=topalign=right>选择图片:</TD><TDalign=left><inputtype="file"disabled=truename="file"></TD></TR><TRid=pricearea><TDvAlign=topalign=right>价 格:</TD><TDalign=left><INPUTname=priceid="price"size=10>RMB(单位:元) </TR><TR><TDvAlign=topalign=right>联系人:</TD><TDalign=left><INPUTname=linkManid="linkMan"maxLength=15></TD></TR><TR><TDvAlign=topalign=right>联系电话:</TD><TDalign=left><INPUTname=telephoneid="telephone"maxLength=20></TD></TR><TR><TDcolSpan=2><INPUTtype=submitvalue="保存"name=submit1></TD></TR></TABLE></FORM></div></body></html>
解决方案
本帖最后由 fldsun 于 2011-03-15 13:18:25 编辑
解决方案二:
该回复于2011-03-15 14:39:23被版主删除
解决方案三:
初始化是不是有问题?空指针啊,27:myUpload.initialize(pageContext);28:29:if(myUpload.getRequest().getParameter("isReUpload").equals("1")){确定了isReUpload的作用域了没?
解决方案四:
把if(myUpload.getRequest().getParameter("isReUpload").equals("1"))之后能运行
解决方案五:
就不能按格式来放代码?这样看好累啊··
解决方案六:
我发现是因为smartupload不能传递radio的值造成的,请问有没有办法传递radio的值?
解决方案七:
空指针呢