NutzCN Logo
问答 文件上传时候使用复合对象数据,通过JSON.stringify以后数据到后台时,变成数组,值出错。
发布于 2209天前 作者 qq_046f8286 2558 次浏览 复制 上一个帖子 下一个帖子
标签:
前台传入的数据:
{"businessTableName":"M_EMPLOYEE","fileContentTypeName":"员工","mEmployeePojo":{"id":"201803261219410154","companyId":"2","customerId":"1830","customerStoreId":"1831","customerPositionId":"1832","name":"吴子美","nationId":"45","idCardExpireDate":"2020-03-31","passportNo":"","visaIssueDate":"","visaExpireDate":"","birthday":"1996-03-07","ethnicityId":"1","isHealthReport":"","healthReportStartDate":"","avatarFileId":"C:\\fakepath\\IMG_0017.JPG","isDisabledPeople":"6","disabledPart":"","disabledLevel":"","areaName":"","areaId":"","siHkxzId":"","welfareName":"","welfareId":"","salaryBase":"","lastBase":"false","supplierId":"","needStartMonth":"","addType":"","serviceFee":"","autoAdd":"false","autoSupplement":"false","siWelfareNeedIds":"","newSalaryBase":"","newLastBase":"false","editStartMonth":"","idCardAddress":"45245","hkAddress":"45245","localAddress":"45245","legalDeliveryAddress":"45245","legalDeliveryTel":"16516816486","legalDeliveryEmail":"34132asd@qq.com","emergencyContact":"武铁","emergencyRelationship":"直系亲属","emergencyTel":"16156461562","mobile":"16156461562","homeTel":"16156461562","customerWantStoreCode":"1615646","customerWantStoreName":"16156","employeeStatusId":"1","leaveDate":"","signDate":"2018-03-26","startDate":"2018-03-26","endDate":"2022-03-28","probationMonth":"6","siWorkdate":"2018-03-26","recruiterUserId":"201802011629090710","isNotice":"false","bankId":"207","bankAccount":"24374533453","bankOpenName":"中国人民银行田东县支行","bankOpenCode":"1626379904","siMedicalHandbookNo":"421321","isSpecificDisease":"6","specificDiseaseReason":"","isMedicalPeriod":"6","medicalPeriodStartDate":"","medicalPeriodEndDate":"","memo":"42132141","sexId":"181"},"siWelfareNeed":[]}
后台获取的数据片段:
{0={, 1=, 2=b, 3=u, 4=s, 5=i, 6=n, 7=e, 8=s, 9=s, 10=T, 11=a, 12=b, 13=l, 14=e, 15=N, 16=a, 17=m, 18=e, 19=, 20=:, 21=, 22=M, 23=_, 24=E, 25=M, 26=P, 27=L, 28=O, 29=Y, 30=E, 31=E, 32=, 33=,, 34=, 35=f, 36=i, 37=l, 38=e, 39=C, 40=o, 41=n, 42=t, 43=e, 44=n, 45=t, 46=T, 47=y, 48=p, 49=e, 50=N, 51=a, 52=m, 53=e, 54=, 55=:, 56=, 57=员, 58=工, 59=, 60=,, 61=, 62=m, 63=E, 64=m, 65=p, 66=l, 67=o, 68=y, 69=e, 70=e, 71=P, 72=o, 73=j, 74=o, 75=, 76=:, 77={, 78=, 79=i, 80=d, 81=, 82=:, 83=, 84=2, 85=0, 86=1, 87=8, 88=0, 89=3, 90=2, 91=6, 92=1, 93=2, 94=1, 95=9, 96=4, 97=1, 98=0, 99=1, 100=5, 101=4, 102=, 103=,, 104=, 105=c, 106=o, 107=m, 108=p, 109=a, 110=n, 111=y, 112=I, 113=d, 114=, 115=:, 116=, 117=2, 118=, 119=,, 120=, 121=c, 122=u, 123=s, 124=t, 125=o, 126=m, 127=e, 128=r, 129=I, 130=d, 131=, 132=:, 133=, 134=1, 135=7, 136=9, 137=8, 138=, 139=,, 140=, 141=c, 142=u, 143=s, 144=t, 145=o, 146=m, 147=e, 148=r, 149=S, 150=t, 151=o, 152=r, 153=e, 154=I, 155=d, 156=, 157=:, 158=, 159=1, 160=7, 161=9, 162=9, 163=, 164=,, 165=, 166=c, 167=u, 168=s, 169=t, 170=o, 171=m, 172=e, 173=r, 174=P, 175=o, 176=s, 177=i, 178=t, 179=i, 180=o, 181=n, 182=I, 183=d, 184=, 185=:, 186=, 187=1, 188=8, 189=0, 190=0, 191=, 192=,, 193=, 194=n, 195=a, 196=m, 197=e, 198=, 199=:, 200=, 201=吴, 202=子, 203=美, 204=, 205=,, 206=, 207=n, 208=a, 209=t, 210=i, 211=o, 212=n, 213=I, 214=d, 215=, 216=:, 217=, 218=4, 219=5, 220=, 221=,, 222=, 223=i, 224=d, 225=C, 226=a, 227=r, 228=d, 229=, 230=:, 231=, 232=1, 233=5, 234=6, 235=1, 236=5, 237=6, 238=4, 239=6, 240=8, 241=1, 242=5, 243=6, 244=4, 245=1, 246=2, 247=1, 248=2, 249=5, 250=, 251=,, 252=, 253=i, 254=d, 255=C, 256=a, 257=r, 258=d, 259=E, 260=x, 261=p, 262=i, 263=r, 264=e, 265=D, 266=a, 267=t, 268=e, 269=, 270=:, 271=, 272=2, 273=0, 274=2, 275=0, 276=-, 277=0, 278=3, 279=-, 280=3, 281=1, 282=, 283=,, 284=, 285=p, 286=a, 287=s, 288=s, 289=p, 290=o, 291=r, 292=t, 293=N, 294=o, 295=, 296=:, 297=, 298=, 299=,, 300=, 301=v, 302=i, 303=s, 304=a, 305=I, 306=s, 307=s, 308=u, 309=e, 310=D, 311=a, 312=t, 313=e, 314=, 315=:, 316=, 317=, 318=,, 319=, 320=v, 321=i, 322=s, 323=a, 324=E, 325=x, 326=p, 327=i, 328=r, 329=e, 330=D, 331=a, 332=t, 333=e, 334=, 335=:, 336=, 337=, 338=,, 339=, 340=b, 341=i, 342=r, 343=t, 344=h, 345=d, 346=a, 347=y, 348=, 349=:, 350=, 351=1, 352=9, 353=9, 354=6, 355=-, 356=0, 357=3, 358=-, 359=0, 360=7, 361=, 362=,, 363=, 364=e, 365=t, 366=h, 367=n, 368=i, 369=c, 370=i, 371=t, 372=y, 373=I, 374=d, 375=, 376=:, 377=, 378=1, 379=, 380=,, 381=, 382=i, 383=s, 384=H, 385=e, 386=a, 387=l, 388=t, 389=h, 390=R, 391=e, 392=p, 393=o, 394=r, 395=t, 396=, 397=:, 398=, 399=, 400=,, 401=, 402=h, 403=e, 404=a, 405=l, 406=t, 407=h, 408=R, 409=e, 410=p, 411=o, 412=r, 413=t, 414=S, 415=t, 416=a, 417=r, 418=t, 419=D, 420=a, 421=t, 422=e, 423=, 424=:, 425=, 426=, 427=,, 428=, 429=a, 430=v, 431=a, 432=t, 433=a, 434=r, 435=F, 436=i, 437=l, 438=e, 439=I, 440=d, 441=, 442=:, 443=, 444=C, 445=:, 446=\, 447=\, 448=f, 449=a, 450=k, 451=e, 452=p, 453=a, 454=t, 455=h, 456=\, 457=\, 458=I, 459=M, 460=G, 461=_, 462=0, 463=0, 464=1, 465

上传方法。

$.ajaxFileUpload({
		url : url, // 用于文件上传的服务器端请求地址
		fileElementId : inputFile, // 文件对象
		dataType : 'comment', // 返回值类型 一般设置为json
		data : JSON.stringify(tempJsonObj),
		cache : false,
		async : false,
		timeout : 8000, // 超时
接收方法
@At("/addEmployee")
	@Ok("json")
	@AdaptBy(type=WhaleAdaptor.class)
	public Object addEmployee(@Param("avatarFileId") TempFile tf, @Param("..") Map map) {
}
5 回复

不能混着的

可以通过改变业务来实现,不过我想知道,为什么数据会被再次包装一层,变成数组。

file与业务数据不能混?

是json跟file不能混

我用的是WhaleAdaptor,也不能混?可是这样的数据

{"businessTableName":"M_EMPLOYEE","fileContentTypeName":"员工"}

Map里面是能够正常拿到数据的。
这块我们修改了,以前都是将json字符串里面的mEmployeePojo对象,通过特殊处理,使其成为纯字符串。
也能够通过map拿到,但是现在是因为有mEmployeePojo对象在字符串里面,没有特殊处理,就变成数组了.

添加回复
请先登陆
回到顶部