看看这个:怎么传输不了变量了??

MeE 2002-08-23 04:33:51
1.jsp==============
<form action="get.jsp" method="post" enctype="multipart/form-data" name="form1"> <input name="fname" type="text" id="fname" value="<%=a%>" size="75"> <input name="tid" type="hidden" id="tid" value="<%=id%>"> <input name="file" type="file" size="60"> <input type="submit" name="Submit" value=" 完 成 " > <input name="Submit2" type="button" onClick="MM_goToURL'parent','cancle.jsp?id=<%=id%>');return document.MM_returnValue" value=" 取 消 ">
</form>
2.jsp=========================
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,com.jspsmart.upload.*" errorPage="" %>
<jsp:useBean id="file" scope="page" class="com.jspsmart.upload.SmartUpload" />
<jsp:useBean id="leidb" scope="page" class="db.linkmysql" />
<%
file.initialize(pageContext);
String id=request.getParameter("id");
out.print(id);
out.close();%>
,,,,,,,
它给我输出个null,气死了!!!!
还有就是用隐含表单域传输中文的时候,中文接收有问题!怎么解决?
...全文
20 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
dearlori 2002-08-23
  • 打赏
  • 举报
回复
file.initialize(pageContext);
file.upload();
String id = file.getRequest().getParameter("id");
....
中文接收问题:
接受页面:
String param=java.net.URLDecoder.decode((String)request.getParameter(str));
利而不害 2002-08-23
  • 打赏
  • 举报
回复
关于中文显示页面中加
<%@ page contentType="text/html;charset=gb2312" %>

接收:
<%=new String(Request.getParameter("name").getBytes("ISO8859_1"), "GB2312")%>
Tomcat4 2002-08-23
  • 打赏
  • 举报
回复
file.initialize(pageContext);
file.upload();
String id=file.getRequest().request.getParameter("id");//该成这样
out.print(id);
out.close();%>
MeE 2002-08-23
  • 打赏
  • 举报
回复
哦 晓得了 已经解决了 给你们加分了哈
guoxiangjing 2002-08-23
  • 打赏
  • 举报
回复
在上传文件时,要指定enctype="multipart/form-data",当有这个指定时,Request.getParameter("")是不会得到任何值的。所以不用费劲从request里得了。用jspsmart upload应该就可以了。
secball 2002-08-23
  • 打赏
  • 举报
回复
这个bean带有很多例子,对于这种情况可以说是有非常好的示范,解压后看一下就行了,用不着在这里浪费时间。
MeE 2002-08-23
  • 打赏
  • 举报
回复
up!
怎么没有看啊?
MeE 2002-08-23
  • 打赏
  • 举报
回复
照null不误!! 我对它没有语言了!
=============
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,com.jspsmart.upload.*" errorPage="" %>
<jsp:useBean id="file" scope="page" class="com.jspsmart.upload.SmartUpload" />
<jsp:useBean id="leidb" scope="page" class="db.linkmysql" />
<%
file.initialize(pageContext);


file.setTotalMaxFileSize(104857600);
file.setAllowedFilesList("doc,exe,txt,pdf");
try{
file.upload();
}
catch(Exception e){
out.println("<font color=red>上传失败</font> <a href=\"JavaScript:window.history.back();\">返回重试</a><br>");
out.println("<UI>错误信息:</UI>");
out.println("<UL>可能你的文件已经超过<font color=red>100MB</font>了.</UL>");
out.println("<UL>可能你的文件类型不对,仅允许上传<font color=red>doc,exe,txt,pdf</font>格式.</UL>");
//leidb.executeUpdate("DELETE FROM file WHERE id="+id);
return;
}
String id=file.getRequest().getParameter("a");
out.print(id);
out.close();
String name=request.getParameter("filename");
String extname=file.getFiles().getFile(1).getFileExt();
String type=file.getFiles().getFile(1).getTypeMIME();
String fullname="/jsp/files/" +name+"."+extname;
fullname=fullname.toLowerCase();
out.print(fullname);
//file.getFiles().getFile(1).saveAs(fullname);
//leidb.executeUpdate("UPDATE file SET url='"+fullname+"' WHERE id="+id);
%>

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧