16Jiaqing 2014-03-05 03:34 采纳率: 0%
浏览 1579

用Ajax请求道action中执行了方法但没有显示结果怎么回事

Ajax中
//导出方法
function exportGo(url,params,grid) {

     $.messager.confirm('提示','您正要导出此项 !<br />请确定继续?',function(r){
         if(r){
             doAjax3("", url, grid, params, "");
         }
    });
}

function doAjax3(form,url,grid,param,msg){
    $.ajax({
        url: url,
        type: 'POST',
        cache: false,
        async: false,
        contentType:"application/json",
    //  dataType : 'json',
        data:  param,
        success: function(data, textStatus, jqXHR) {
            alert(data);
            if (!isNull(grid)) {
                grid.load({page:1});
            }   
            if(!isNull(form)){
                form.resetForm();
            }


        },
        error:function(msg,textStatus, errorThrown) {
            alert(errorThrown);
            alert("网络错误或者处理异常,请重试或者联系管理员处理!错误信息:" + msg.responseText);
        }
   });
}

action中
/**
* 导出model的xml文件
*/
@RequestMapping(value = "export/{modelId}")
@OperatingLog(function="导出文件")
public void export(@PathVariable("modelId") String modelId,
HttpServletResponse response) {
try {
Model modelData = repositoryService.getModel(modelId);
BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
JsonNode editorNode = new ObjectMapper().readTree(repositoryService
.getModelEditorSource(modelData.getId()));
BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode);
BpmnXMLConverter xmlConverter = new BpmnXMLConverter();
byte[] bpmnBytes = xmlConverter.convertToXML(bpmnModel);

        ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes);
        IOUtils.copy(in, response.getOutputStream());
        String filename = bpmnModel.getMainProcess().getId()
                + ".bpmn20.xml";
        response.setHeader("Content-Disposition", "attachment; filename="
                + filename);
        response.flushBuffer();
    } catch (Exception e) {
        log.error("导出model的xml文件失败:modelId={}", modelId, e);
    }
}
  • 写回答

1条回答

  • CSDN-Ada助手 CSDN-AI 官方账号 2022-10-30 07:59
    关注
    不知道你这个问题是否已经解决, 如果还没有解决的话:

    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^
    评论

报告相同问题?

悬赏问题

  • ¥15 求帮我调试一下freefem代码
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图