2019独角兽企业重金招聘Python工程师标准>>> hot3.png

<%@ page contentType="text/html; charset=GBK" language="java"%>
<%@ page import="gap.rm.tools.helper.RmVoHelper"%>
<%@ taglib uri="reference" prefix="r"%>
<%@page import="sgcc.htjs.contract.util.IContractConstants"%>
<html>
<head>
<%@ include file="/jsp/include/global.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>编辑技术变更单</title>
<script language="javascript">
        var rootPath = '<%=request.getContextPath()%>';//根路径
        $(document).ready(function() {
        alert()
           
        });
    
    
    function upload_free_file(){
        $("#con_edit_form").get(0).action = "<%=request.getContextPath()%>/ConChangeApplyAction.do?cmd=ajaxFormSubmit";
        $("#con_edit_form").get(0).target = "form_iframe";//修改form重定到iframe中,模拟异步上传文件的效果
        try{
            $('#con_edit_form').get(0).encoding = "multipart/form-data"; //IE+
        }catch(err){
            $("#con_edit_form").get(0).enctype = "multipart/form-data";
        }
        $("#con_edit_form").submit();
    }
           $(document).ready(function() {
                $("#form_iframe").get(0).onload = function(){
                debugger;
                //获得返回的json信息等
                    var result_str = $("#form_iframe").get(0).contentWindow.document.body.innerHTML;
                    if(!result_str){
                      result_str = $("#form_iframe").get(0).contentWindow.document.documentElement.innerHTML;
                    }
                    alert(result_str);
                  }
             });
             //save
             function conApplySave(){
                    $("#con_edit_form").get(0).action = "<%=request.getContextPath()%>/ConChangeApplyAction.do?cmd=conApplySave";
                     try{
                        $("#con_edit_form").get(0).enctype = "";
                    }catch(err){
                    }
                     try{
                         $('#con_edit_form').get(0).encoding = "";//IE+
                    }catch(err){
                    }
                    $("#con_edit_form").submit();
             }
             //这种方式可以实现ifram不刷新页面,异步上传文件的效果,并能完成验证。
             /**
             //frame上传验证数据
  public IForward ajaxFormSubmit(DefaultForm formBean, IRequest request, IResponse response) throws Exception {
      String jsonString = "";
      HttpServletRequest hRequest=(HttpServletRequest) request.getServletRequest();
      //创建上传附件解析器,目前只支持默认创建
      FileUploador fu = FileUploadorFactory.createInstance();
      try {
          //判断是否文件二进制提交
            fu.parse(hRequest);
          //设置最大只允许附件大小
            fu.setSizeMax(10*1024*1024*10); //100M
                String test_x = fu.getParamterString("test_x");
                //获取附件对象.
                //如果附件对象不存在,或者大小、类型不符合要求,则返回null
                FileInfo fi = fu.getFileInfo("free_filename");
                if(null != fi){
                    InputStream file_in = fi.getFile();
                    POIFSFileSystem pois = new POIFSFileSystem(file_in);
                    HSSFWorkbook wb = new HSSFWorkbook(pois);
                    HSSFSheet sheet = wb.getSheetAt(0);
                    int length=sheet.getLastRowNum();
                    String str = sheet.getRow(0).getCell(0).toString();
                    System.out.println(str);
                    jsonString = "{'status':'200','contractinfo_id':'121212212','result':'"+str+"'}";
                }
        } catch (Exception e) {
            e.printStackTrace();
            jsonString = "{'status':'203','contractinfo_id':'121212212','result':''}";
        }
        TooolUtil.setTextAjax(jsonString,response);
        return null;
  }
  public IForward conApplySave(DefaultForm formBean, IRequest request, IResponse response) throws Exception {
      String test_x = request.getParameter("test_x");
      System.out.println(test_x);
      return request.findForward("con_change_list");
  }
             */
</script>
</head>
<body>
<script language="javascript">
    writeTableTop('列表页面','<%=request.getContextPath()%>/');  //显示本页的页眉
</script>
        <form  name="con_edit_form" id="con_edit_form" enctype="multipart/form-data" method="post">
            <input type="hidden" name="cmd" value="ajaxFormSubmit"/>
            <input type="text" name="test_x" value=""/>
            <input type="file" name="filename" value=""/>
            <input name="button_return" id="button_return"
                        class="button_ellipse" type="button" value="提交"
                        οnclick="javascript:upload_free_file();">

</form>
        <script language="javascript">
    writeTableBottom('<%=request.getContextPath()%>/');  //显示本页的页脚
</script>
</body>
</html>
<script language="javascript">
<%  //表单回写
    if(request.getAttribute(IContractConstants.REQUEST_WRITE_BACK_FORM_VALUES) != null) {  //如果request中取出的表单回写bean不为空
        out.print(RmVoHelper.writeBackMapToForm((java.util.Map)request.getAttribute(IContractConstants.REQUEST_WRITE_BACK_FORM_VALUES)));  //输出表单回写方法的脚本
    }
%> 
</script>

转载于:https://my.oschina.net/u/1052786/blog/1505399

修改form重定到iframe中,模拟异步上传文件的效果相关推荐

  1. Java中模拟POST上传文件

    /**** @param url 请求URL* @param filePath 本地文件地址* @return*/public static String upload(String url,Stri ...

  2. html中异步上传文件实现示例,HTML_html中异步上传文件实现示例,复制代码代码如下: form actio - phpStudy...

    html中异步上传文件实现示例 复制代码代码如下: 复制代码代码如下: 这是html中最常见最简单的表单提交方式,但是这种方式必须会切换页面,也许有些时候我们希望可以在同一个页面与服务器进行交互,并不 ...

  3. javaweb中运用fileupload上传文件

    本文是介绍javaweb开发运用Apache中的commons fileupload的commons io的工具来进行文件上传,在开发中会遇到很多比较棘手的问题,本人接触后进行了总结. 开发准备: 去 ...

  4. android项目中使用的服务器上,android 开发中使用okhttp上传文件到服务器

    开发android手机客户端,常常会需要上传文件到服务器,比如:你手机里的照片. 使用okhttp会是一个很好的选择.它使用很简单,而且运行效率也很高. 首先,在 app/build.gradle 的 ...

  5. ajax上传 java,javaWeb中使用ajax上传文件

    javaWeb上传图片 上传文件所必要的两个jar包:commons-fileupload.jar.commons-io.jar. 核心代码: String withPath = req.getSer ...

  6. python模拟浏览器上传文件_Python模拟浏览器上传文件脚本的方法(Multipart/form-data格式)...

    http协议本身的原始方法不支持multipart/form-data请求,这个请求由原始方法演变而来的. multipart/form-data的基础方法是post,也就是说是由post方法来组合实 ...

  7. php curl文件上传,在 php 中通过 CURL 上传文件

    1.使用 CURL 默认的方法$file = realpath('gif/1.gif'); //要上传的文件 $fields['f'] = '@'.$file; $ch = curl_init(); ...

  8. JS中使用FormData上传文件、图片的方法

    参考博客:http://www.cnblogs.com/xiaohuochai/p/6543019.html http://www.cnblogs.com/qcloud1001/p/6839541.h ...

  9. java 模拟post上传文件_JAVA模拟HTTP post请求上传文件

    在开发中,我们使用的比较多的HTTP请求方式基本上就是GET.POST.其中GET用于从服务器获取数据,POST主要用于向服务器提交一些表单数据,例如文件上传等.而我们在使用HTTP请求时中遇到的比较 ...

最新文章

  1. 常用的数据交换格式有哪些_Linux后台开发6大常用的开源库,让你在同行中脱颖而出...
  2. 创业路上的这点事之 从无到有,从有到......
  3. 面试总结----java初级工程师
  4. note deletion case
  5. html写出日出,描写日出优美句子
  6. CentOS上搭建Nginx + Mono 运行 asp.net
  7. mac下的secureCRT.8的设置
  8. 特斯拉进入Autopilot 2.0时代,高举“普通雷达”旗帜!
  9. [转载] Python 学习笔记 迭代器和生成器
  10. Python图片文字识别——Windows下Tesseract-OCR的安装与使用
  11. 《Android进阶解密》— Android 书籍
  12. 退火算法(Annealing)简介与详解
  13. 微信小程序:实现按钮点击事件
  14. 容联云(第三方短信发送)
  15. 电脑开机启动项选择快捷键大全
  16. 2021年编程类书籍推荐清单
  17. ADMIN云计算系统管理
  18. 搭建通过openOCD下载mini2440程序的调试平台
  19. maven 引用其他项目引用的包出现BOOT-INF问题
  20. ISO26262解析(十)——HSI

热门文章

  1. python爬取热门新闻每日排行_爬取网易新闻排行榜
  2. QQ原生SDK第三方登录
  3. 华为ensp.访问控制列表(ACL):关于基本ACL和高级ACL————访问的代码基础讲解(允许或禁止访问)
  4. 采煤机远程监测与故障诊断系统
  5. 一分钟应对勒索病毒WannaCry
  6. 小米活塞耳机的背后——1MORE
  7. Python的函数drop_duplicates参数说明
  8. 游戏设计自学记录(1)
  9. 排序算法(二):快速排序
  10. Winform MessageBox.Show时居中到主页面