afinal 上传文件服务端接受参数为空

做个了上传和提交数据的测试,遇到点问题,如果只加 string类型的参数,server端接受到参数没问题,如果加上file类型的,server端servlet 接受到参数都为空了。

代码如下

FinalHttp fh = new FinalHttp();

    AjaxParams params = new AjaxParams(); 
    params.put("action", "test"); 
params.put("username", "aaaaa"); 
    try { 
params.put("file",new File("/mnt/sdcard/1.jpg")); 
} catch (FileNotFoundException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 



    fh.post(serverUrl,params, new AjaxCallBack<Object>() { 
     
    @Override 
    public void onLoading(long count, long current) { 
    super.onLoading(count, current); 
    } 
    @Override 
    public void onSuccess(Object t) { 
    // TODO Auto-generated method stub 
    logger.info("返回信息是+"+ t.toString()); 
    } 
});

文章转载于网络,如有侵权,请原创留言;内容如有不妥,请各位园友提宝贵意见或建议。所有文章均处于编辑状态。。。。。。百度贴吧:流水小桥吧 如有问题,请点击页面左上角“给我写信”发邮件留言!
原文地址:https://www.cnblogs.com/flyoung/p/4845456.html