回 帖 发 新 帖 刷新版面

主题:[讨论]求教:SmartUpload 传值为空的问题

各位,小弟在tomcat+netbean下,使用SmartUpload 来实现上传功能,因此form里面必须注明:
encType="multipart/form-data" ,可是这样的话,就会导致其他控件的值无法在页面之间通过request.getParameter()来传递,根据网上的说法,应该是直接使用SmartUpload 的方法getRequest().getParameter()来实现的,但是我明明是用了的,为什么取值还是为空呢?我的代码如下,请各位帮忙看下吧,谢谢了!
前台页面:
<%@page contentType="text/html" pageEncoding="gb2312" import="java.sql.*" import ="com.jspsmart.upload.*"  %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
   <jsp:useBean id="db" class="org.netbeans.Web.connectDB" />
   <jsp:useBean id="nowtime" class="org.netbeans.Web.nowtime" />
   <jsp:useBean id="mySmartUpload" scope = "session" class="com.jspsmart.upload.SmartUpload" />
   <jsp:setProperty name="mySmartUpload" property="*" />




<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
        <title>公告栏</title>
    </head>
    <body>
        <form name="form1" method="post" encType="multipart/form-data" action="noticeadd2.jsp"  >
            <input type="hidden" name="isfirst" value="1">
            <table border="1" width="400" cellspacing="1" cellpadding="4"  align=center>
                    <tr>
                        <td height="25" colspan="2" bgcolor="#FFFFFF" ><div align="center">发布公告</div></td>
                    </tr>
                    <tr>
                        <td><font size="2">标题:</font></td>
                        <td><input type="text" name="noticetitle" value="" size="50" /></td>
                    </tr>
                    <tr>
                        <td><font size="2">内容:</font></td>
                        <td>
                            <textarea name="noticecontent" value ="" rows="15" cols="40">
                            </textarea>
                        </td>
                    </tr>
                    <tr>
                        <td><font size="2">上传附件:</font></td>
                        <td>
                            <input type="file" name="uploadfile" value="uploadfile" width="105" />
                         </td>
                    </tr>
                    <tr>
                         <td height="25" colspan="2"  ><div align="center"><input type="submit" name="Submit" value="提交"></div></td>
                    </tr>
            </table>
                
        </form>

            
    </body>
</html>

后台的测试页面:noticeadd2.jsp

<%@page contentType="text/html" pageEncoding="gb2312" import="java.sql.*" import ="com.jspsmart.upload.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="db" class="org.netbeans.Web.connectDB" />
   <jsp:useBean id="nowtime" class="org.netbeans.Web.nowtime" />
   <jsp:useBean id="mySmartUpload" scope = "session" class="com.jspsmart.upload.SmartUpload" />
  
   <%
   //mySmartUpload.initialize(pageContext);
   mySmartUpload.initialize(pageContext);
   //mySmartUpload.getRequest().getParameter("isfirst");
   String isfirst = mySmartUpload.getRequest().getParameter("isfirst");
   if(isfirst == null)
         {
            out.print("+isfirst+");
         isfirst= "";
        out.print(""+isfirst+"");
         }
   %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312 ">
        <title>test </title>
    </head>
    <body>
        <h1>Hello World!</h1>
    </body>
</html>


哎,每次都会进入if(isfirst == null)的那个循环哎,我彻底无语的,好几天了,都,请大家帮忙看看吧,谢谢了!

回复列表 (共1个回复)

沙发

已经解决

我来回复

您尚未登录,请登录后再回复。点此登录或注册