smartupload上传文件疑难杂症

    最近看了通过smartupload怎么上传文件,虽然smartupload有很多局限性,已经不用了,但还是看一看。遇到了一个奇怪的问题。 

    html文件代码如下,文件名upload.html:

   <html>
  <head>
    <title>upload.html</title>
  </head>
  <body>
      <form action="smartupload.jsp" method="post" enctype="multipart/form-data">
               新文件名称:    <input type="text" name="uname"><br>
               选择上传的文件:<input type="file" name="sf"><br>
      <input type="submit" value="上传" />
      </form>
  </body>
  </html>

jsp处理代码如下,文件名smartupload.jsp

<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<jsp:useBean id="smartupload" class="org.lxh.smart.SmartUpload"/>
<html>
<head>
<title>smartupload</title>
</head>
<body>
<%
request.setCharacterEncoding("GBK") ;
smartupload.initialize(pageContext) ; // 初始化上传
smartupload.upload() ; // 准备上传
String name = smartupload.getRequest().getParameter("uname") ;
smartupload.save("upload") ; // 保存文件
%>
<h1><%=name%></h1>
</body>
</html>

    由于通过smartupload上传文件时,需要封装,因此不能直接通过request.getParameter("uname");取得参数值,只能通过smartupload.getRequest().getParameter("uname") ;取得页面提交过来的表单元素值,但按照上述代码,死活就是取不能uname的值,代码没一点问题,无奈之下将

upload.html的后缀名改成htm后,好使了,特别惊讶,因为html与htm的后缀,通过MIME解析都是相同的,不知道为什么?大家有没有遇到过这种情况?

    

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值