smartupload的问题,求助
Simple01.html<formaction="Simple01.jsp"method="post"ENCTYPE="multipart/form=data">输入名...
Simple01.html
<form action="Simple01.jsp" method="post" ENCTYPE="multipart/form=data">
输入名称:<input type="text" name="ino"><br>
选择要上传的图片:
<input type="file" name="pic">
<input type="submit" value="上传">
</form>
----------------------------------------------------
Simple01.jsp
<%@ page contentType="text/html;charset=gb2312" %>
<jsp:useBean id="smart" scope="page" class="com.jspsmart.upload.SmartUpload"/>
<%
smart.initialize(pageContext);
smart.upload();
smart.save("/upload");
%>
<%
String name = smart.getRequest().getParameter("ino");
%>
<h1><%=name%></h1>
------------------------------------------------------------------------
可是图片没有出现在文件夹里,而且取不到值,在Simple01.jsp中显示的是null。这是怎么回事儿,这个代码我看了很多遍了,应该没有问题,会不会是smartupload.jar有问题?
现在我又试着把Simple01.jsp改一下,如下:
<%@ page contentType="text/html;charset=gb2312" %>
<jsp:useBean id="smart" scope="page" class="com.jspsmart.upload.SmartUpload"/>
<%
smart.initialize(pageContext);
smart.upload();
String ext = smart.getFiles().getFile(0).getFileExt();
%>
<%
String name = smart.getRequest().getParameter("ino");
%>
<h1><%=name+"."+ext%></h1>
改完就报错了,报错如下:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /Simple01.jsp at line 6
3: <%
4: smart.initialize(pageContext);
5: smart.upload();
6: String ext = smart.getFiles().getFile(0).getFileExt();
7: %>
8: <%
9: String name = smart.getRequest().getParameter("ino");
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:428)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.IllegalArgumentException: Files' name is invalid or does not exist (1205).
com.jspsmart.upload.Files.getFile(Files.java:73)
org.apache.jsp.Simple01_jsp._jspService(Simple01_jsp.java:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs. 展开
<form action="Simple01.jsp" method="post" ENCTYPE="multipart/form=data">
输入名称:<input type="text" name="ino"><br>
选择要上传的图片:
<input type="file" name="pic">
<input type="submit" value="上传">
</form>
----------------------------------------------------
Simple01.jsp
<%@ page contentType="text/html;charset=gb2312" %>
<jsp:useBean id="smart" scope="page" class="com.jspsmart.upload.SmartUpload"/>
<%
smart.initialize(pageContext);
smart.upload();
smart.save("/upload");
%>
<%
String name = smart.getRequest().getParameter("ino");
%>
<h1><%=name%></h1>
------------------------------------------------------------------------
可是图片没有出现在文件夹里,而且取不到值,在Simple01.jsp中显示的是null。这是怎么回事儿,这个代码我看了很多遍了,应该没有问题,会不会是smartupload.jar有问题?
现在我又试着把Simple01.jsp改一下,如下:
<%@ page contentType="text/html;charset=gb2312" %>
<jsp:useBean id="smart" scope="page" class="com.jspsmart.upload.SmartUpload"/>
<%
smart.initialize(pageContext);
smart.upload();
String ext = smart.getFiles().getFile(0).getFileExt();
%>
<%
String name = smart.getRequest().getParameter("ino");
%>
<h1><%=name+"."+ext%></h1>
改完就报错了,报错如下:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /Simple01.jsp at line 6
3: <%
4: smart.initialize(pageContext);
5: smart.upload();
6: String ext = smart.getFiles().getFile(0).getFileExt();
7: %>
8: <%
9: String name = smart.getRequest().getParameter("ino");
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:428)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.IllegalArgumentException: Files' name is invalid or does not exist (1205).
com.jspsmart.upload.Files.getFile(Files.java:73)
org.apache.jsp.Simple01_jsp._jspService(Simple01_jsp.java:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs. 展开
1个回答
展开全部
mySmartUpload.initialize(pageContext);
mySmartUpload.upload();
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
String path = request.getSession().getServletContext().getRealPath("/upload");
myFile.saveAs(path + "/" + 文件名 + "." + myFile.getFileExt());
mySmartUpload.upload();
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
String path = request.getSession().getServletContext().getRealPath("/upload");
myFile.saveAs(path + "/" + 文件名 + "." + myFile.getFileExt());
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询