日期:2014-05-20  浏览次数:20834 次

<span id>函数回调不成功
用iframe进行文件异步上传时  函数回调一直不起作用即><br><span id="msg"></span>一直不起作用啊index.jsp



<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

<script type="text/javascript">              
function callback(msg){  
document.getElementById("file").outerHTML =document.getElementById("file").outerHTML;                 
 document.getElementById("msg").innerHTML = msg;                   
   document.getElementById("path").value=msg;              }         
    </script> 

  </head>
  
  <body>
 <form action="servlet/upLoad" method="post" enctype="multipart/form-data" target="uploadIframe">            
 添加附件:<input type="file" name="upload"/>            
 <input type="submit" value="上传"/><br><span id="msg"></span></form>      
   <iframe name="uploadIframe" id="uploadIframe" style="display:none"></iframe>  
  </body>
</html>



upLoad.java
package cat;

import java.io.*;
import java.util.Calendar;



import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.jspsmart.upload.SmartUpload;
public class upLoad extends HttpServlet {
/**
 * 
 */
private static final long serialVersionUID = 1L;
private ServletConfig config;
final public void init(ServletConfig config) throws ServletException{
this.config=config;
}
public String handleString(String s){
try{
byte bb[]=s.getBytes("iso-8859-1");
s=new String(bb);
}
catch(Exception ee){ee.printStackTrace();}