mky136 2017-08-07 09:13 采纳率: 0%
浏览 7478
已采纳

前台报错 415 (Unsupported Media Type)

//异步上传图片 function doploy(){ //定义参数 var options={ url:"rest/process/deploy/", dataType:"text", type:"post", success:function(data){ alert(data); }, error:function(){ alert("upload error"); } }; //使用jquery.form异步上传图片 $("#deployProcess").ajaxSubmit(options); }




请选择发布的流程:
onclick="doploy()" />


@POST
@Path("/deploy/")
@Produces(MediaType.APPLICATION_JSON)
@LogAnnotation(operationName = "发布流程")
public String deployProcess(@RequestParam(required=false) MultipartFile processDef) {

ZipInputStream zis = null;
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
.getRequestAttributes()).getRequest();
try {
request.setCharacterEncoding("UTF-8");
String deployFile = request.getParameter("processDef");
if (deployFile != null && !deployFile.isEmpty()) {
ProcessEngine processEngine = Configuration.getProcessEngine();
RepositoryService repositoryService = processEngine
.getRepositoryService();

            zis = new ZipInputStream(processDef.getInputStream());
            repositoryService.createDeployment()
                    .addResourcesFromZipInputStream(zis).deploy();
            zis.close();
        } else {
            return GlobalConstant.FAILURE;
        }
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return GlobalConstant.FAILURE;
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return GlobalConstant.FAILURE;
    } finally {
        try {
            if(zis != null){
                zis.close();
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 
    }
    return GlobalConstant.SUCCESS;
}
  • 写回答

3条回答 默认 最新

  • 蚂蚁冲锋队 2017-08-07 09:50
    关注

    var options = {

    target: '#output', //把服务器返回的内容放入id为output的元素中

    beforeSubmit: showRequest, //提交前的回调函数

    success: showResponse, //提交后的回调函数

    url: url, //默认是form的action, 如果申明,则会覆盖

    type: type, //默认是form的method(get or post),如果申明,则会覆盖

    dataType: null, //html(默认), xml, script, json...接受服务端返回的类型

    clearForm: true, //成功提交后,清除所有表单元素的值

    resetForm: true, //成功提交后,重置所有表单元素的值

    timeout: 3000 //限制请求的时间,当请求大于3秒后,跳出请求

    }

    你的程序报的是:不支持的媒体类型,所以定位到dataType字段的属性,你把它换成上面的格式试一下,看看哪一种可以通过

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法