惯例:
我是温浩然:
先说需求:
调用接口,传过json数据,对其进行解析,数据中,有url一栏,不确定是 mp4,还是jpg。
需要分析这个url,然后再页面上,根据类型显示图片或者视频。然后来看看图片或者视频是否合格。
先贴json中的数据:
{"code":"A00000","data":{"tasks":[{"id":331,"bid":1412,"cardId":3,"score":6,"taskType":"health","url":"http://www.baidu.com/img/20150921/5fe010e210710dcec6767f5ce9b4cbfb.jpg","stageId":1,"replaceScore":0,"topScore":0,"reviewNum":1,"img":"","stageSort":1,"noPass":false},{"id":330,"bid":1412,"cardId":5,"score":6,"taskType":"active","url":"http://www.baidu.com/img/20150921/3d56c80bcdddbc71a02f567dc902e138.jpg","stageId":1,"replaceScore":0,"topScore":0,"reviewNum":1,"img":"","stageSort":1,"noPass":true},{"id":327,"bid":70,"cardId":317,"score":2,"taskType":"active","url":"http://www.baidu.com/cms_img/20150514/4EED62321250B9F2808B4705EBE79803.jpg","stageId":29,"replaceScore":0,"topScore":0,"reviewNum":0,"img":"","stageSort":23,"noPass":false},{"id":326,"bid":70,"cardId":316,"score":2,"taskType":"active","url":"http://www.baidu.com/cms_img/20150514/4EED62321250B9F2808B4705EBE79803.jpg","stageId":29,"replaceScore":0,"topScore":0,"reviewNum":0,"img":"","stageSort":23,"noPass":false},{"id":325,"bid":70,"cardId":315,"score":2,"taskType":"active","url":"http://www.baidu.com/cms_img/20150514/4EED62321250B9F2808B4705EBE79803.jpg","stageId":29,"replaceScore":0,"topScore":0,"reviewNum":0,"img":"","stageSort":23,"noPass":false},{"id":324,"bid":70,"cardId":313,"score":2,"taskType":"active","url":"http://www.baidu.com/cms_img/20150514/4EED62321250B9F2808B4705EBE79803.jpg","stageId":29,"replaceScore":0,"topScore":0,"reviewNum":0,"img":"","stageSort":23,"noPass":false},{"id":323,"bid":70,"cardId":312,"score":2,"taskType":"health","url":"http://www.baidu.com/cms_img/20150514/4EED62321250B9F2808B4705EBE79803.jpg","stageId":29,"replaceScore":0,"topScore":0,"reviewNum":0,"img":"","stageSort":23,"noPass":false},{"id":318,"bid":31,"cardId":151,"score":2,"taskType":"health","url":"http://www.baidu.com/baby/20150918/3371567547BE822BF20C2BF24E549AA8.mp4","stageId":1,"replaceScore":0,"topScore":0,"reviewNum":0,"img":"http://www.baidu.com/img/20150918/E46205BC0EAF81B1E76ACD9BB59F1E2D.jpg","stageSort":1,"noPass":false},{"id":317,"bid":31,"cardId":149,"score":2,"taskType":"health","url":"http://www.baidu.com/baby/20150918/55F0DD486DCB1D98EB4FA92C32E0E9B9.mp4","stageId":1,"replaceScore":0,"topScore":0,"reviewNum":0,"img":"http://www.baidu.com/img/20150918/EFE4CD06AF29E258F748E66A57DADCDA.jpg","stageSort":1,"noPass":false},{"id":316,"bid":31,"cardId":148,"score":2,"taskType":"active","url":"http://www.baidu.com/baby/20150918/F003D1FEBDB6405DE4CDABF04BAAF5C7.mp4","stageId":1,"replaceScore":0,"topScore":0,"reviewNum":0,"img":"http://www.baidu.com/img/20150918/B6D0D43A4A51B29E7AF71A5C8A272529.jpg","stageSort":1,"noPass":false},{"id":313,"bid":2053,"cardId":38,"score":3,"taskType":"active","url":"http://www.baidu.com/img/20150918/1cdb7ad4784209c57a0008cf81ce46a3.jpg","stageId":13,"replaceScore":0,"topScore":0,"reviewNum":2,"img":"","stageSort":7,"noPass":false},{"id":310,"bid":1451,"cardId":148,"score":2,"taskType":"active","url":"http://www.baidu.com/baby/20150918/275436CA950AFE95A49B3A59CDB94598.mp4","stageId":1,"replaceScore":0,"topScore":0,"reviewNum":5,"img":"http://www.baidu.com/img/20150918/6EE5C476BD4F6D5FF8682CCC1E2D1ACD.jpg","stageSort":1,"noPass":false},{"id":301,"bid":2043,"cardId":274,"score":4,"taskType":"active","url":"http://www.baidu.com/baby/20150917/986d3857861b625ea18243fe9247474e.mp4","stageId":22,"replaceScore":0,"topScore":0,"reviewNum":3,"img":"http://www.baidu.com/img/20150917/c22ce3c9047d8b9fee38b7c92751e224.jpg","stageSort":16,"noPass":false},{"id":300,"bid":2043,"cardId":273,"score":5,"taskType":"health","url":"http://www.baidu.com/baby/20150917/e075055ce7f57e11bc936481b35a8e74.mp4","stageId":22,"replaceScore":0,"topScore":0,"reviewNum":3,"img":"http://www.baidu.com/img/20150917/b17aba0636279ed8683ba61c62daa4bd.jpg","stageSort":16,"noPass":false},{"id":299,"bid":1389,"cardId":3,"score":0,"taskType":"health","url":"http://www.baidu.com/img/20150917/37b0fe1f73e8bdec0b0dee2ae696cd05.jpg","stageId":1,"replaceScore":0,"topScore":0,"reviewNum":3,"img":"","stageSort":1,"noPass":false},{"id":290,"bid":29,"cardId":287,"score":0,"taskType":"active","url":"http://www.baidu.com/baby/20150917/8079D13F1A5D9C1F2B68F8393CAD5540.mp4","stageId":24,"replaceScore":0,"topScore":0,"reviewNum":4,"img":"http://www.baidu.com/img/20150917/596BC82D250717E3F415877FC9164421.jpg","stageSort":18,"noPass":false},{"id":289,"bid":29,"cardId":283,"score":0,"taskType":"health","url":"http://www.baidu.com/baby/20150917/B81A0923FCBF27A02CACF88537F86060.mp4","stageId":24,"replaceScore":0,"topScore":0,"reviewNum":3,"img":"http://www.baidu.com/img/20150917/DDFE607FAAB56B0AF61862FDBA8523B5.jpg","stageSort":18,"noPass":false},{"id":288,"bid":29,"cardId":279,"score":0,"taskType":"active","url":"http://www.baidu.com/baby/20150917/479C420B141A62B3E6C4FD11D4F6DCC2.mp4","stageId":24,"replaceScore":0,"topScore":0,"reviewNum":3,"img":"http://www.baidu.com/img/20150917/4CE715152AA42B73593650B7F785F732.jpg","stageSort":18,"noPass":false},{"id":287,"bid":29,"cardId":278,"score":0,"taskType":"active","url":"http://www.baidu.com/baby/20150917/4CCBEC3AF3FF455A616EE5891693DF9E.mp4","stageId":24,"replaceScore":0,"topScore":0,"reviewNum":3,"img":"http://www.baidu.com/img/20150917/EAAD98391D7305F0429584AB881F11EC.jpg","stageSort":18,"noPass":false},{"id":285,"bid":29,"cardId":117,"score":0,"taskType":"active","url":"http://www.baidu.com/img/20150917/2991DC770972638080A9FD8418434430.jpg","stageId":24,"replaceScore":0,"topScore":0,"reviewNum":3,"img":"http://www.baidu.com/img/20150917/2991DC770972638080A9FD8418434430.jpg","stageSort":18,"noPass":false}]}}
看着可能有点迷糊,推荐个网站,在线json格式化网站:
www.bejson.com
在线转换json
下面是转换后的一条记录
{ "code": "A00000", "data": { "tasks": [ { "id": 331, "bid": 1412, "cardId": 3, "score": 6, "taskType": "health", "url": "http://www.baidu.com/img/20150921/5fe010e210710dcec6767f5ce9b4cbfb.jpg", "stageId": 1, "replaceScore": 0, "topScore": 0, "reviewNum": 1, "img": "", "stageSort": 1, "noPass": false }, { "id": 330, "bid": 1412, "cardId": 5, "score": 6, "taskType": "active", "url": "http://www.baidu.com/img/20150921/3d56c80bcdddbc71a02f567dc902e138.jpg", "stageId": 1, "replaceScore": 0, "topScore": 0, "reviewNum": 1, "img": "", "stageSort": 1, "noPass": true }, { "id": 327, "bid": 70, "cardId": 317, "score": 2, "taskType": "active", "url": "http://www.baidu.com/cms_img/20150514/4EED62321250B9F2808B4705EBE79803.jpg", "stageId": 29, "replaceScore": 0, "topScore": 0, "reviewNum": 0, "img": "", "stageSort": 23, "noPass": false }, { "id": 326, "bid": 70, "cardId": 316, "score": 2, "taskType": "active", "url": "http://www.baidu.com/cms_img/20150514/4EED62321250B9F2808B4705EBE79803.jpg", "stageId": 29, "replaceScore": 0, "topScore": 0, "reviewNum": 0, "img": "", "stageSort": 23, "noPass": false }, { "id": 325, "bid": 70, "cardId": 315, "score": 2, "taskType": "active", "url": "http://www.baidu.com/cms_img/20150514/4EED62321250B9F2808B4705EBE79803.jpg", "stageId": 29, "replaceScore": 0, "topScore": 0, "reviewNum": 0, "img": "", "stageSort": 23, "noPass": false }, { "id": 324, "bid": 70, "cardId": 313, "score": 2, "taskType": "active", "url": "http://www.baidu.com/cms_img/20150514/4EED62321250B9F2808B4705EBE79803.jpg", "stageId": 29, "replaceScore": 0, "topScore": 0, "reviewNum": 0, "img": "", "stageSort": 23, "noPass": false }, { "id": 323, "bid": 70, "cardId": 312, "score": 2, "taskType": "health", "url": "http://www.baidu.com/cms_img/20150514/4EED62321250B9F2808B4705EBE79803.jpg", "stageId": 29, "replaceScore": 0, "topScore": 0, "reviewNum": 0, "img": "", "stageSort": 23, "noPass": false }, { "id": 318, "bid": 31, "cardId": 151, "score": 2, "taskType": "health", "url": "http://www.baidu.com/baby/20150918/3371567547BE822BF20C2BF24E549AA8.mp4", "stageId": 1, "replaceScore": 0, "topScore": 0, "reviewNum": 0, "img": "http://www.baidu.com/img/20150918/E46205BC0EAF81B1E76ACD9BB59F1E2D.jpg", "stageSort": 1, "noPass": false }, { "id": 317, "bid": 31, "cardId": 149, "score": 2, "taskType": "health", "url": "http://www.baidu.com/baby/20150918/55F0DD486DCB1D98EB4FA92C32E0E9B9.mp4", "stageId": 1, "replaceScore": 0, "topScore": 0, "reviewNum": 0, "img": "http://www.baidu.com/img/20150918/EFE4CD06AF29E258F748E66A57DADCDA.jpg", "stageSort": 1, "noPass": false }, { "id": 316, "bid": 31, "cardId": 148, "score": 2, "taskType": "active", "url": "http://www.baidu.com/baby/20150918/F003D1FEBDB6405DE4CDABF04BAAF5C7.mp4", "stageId": 1, "replaceScore": 0, "topScore": 0, "reviewNum": 0, "img": "http://www.baidu.com/img/20150918/B6D0D43A4A51B29E7AF71A5C8A272529.jpg", "stageSort": 1, "noPass": false }, { "id": 313, "bid": 2053, "cardId": 38, "score": 3, "taskType": "active", "url": "http://www.baidu.com/img/20150918/1cdb7ad4784209c57a0008cf81ce46a3.jpg", "stageId": 13, "replaceScore": 0, "topScore": 0, "reviewNum": 2, "img": "", "stageSort": 7, "noPass": false }, { "id": 310, "bid": 1451, "cardId": 148, "score": 2, "taskType": "active", "url": "http://www.baidu.com/baby/20150918/275436CA950AFE95A49B3A59CDB94598.mp4", "stageId": 1, "replaceScore": 0, "topScore": 0, "reviewNum": 5, "img": "http://www.baidu.com/img/20150918/6EE5C476BD4F6D5FF8682CCC1E2D1ACD.jpg", "stageSort": 1, "noPass": false }, { "id": 301, "bid": 2043, "cardId": 274, "score": 4, "taskType": "active", "url": "http://www.baidu.com/baby/20150917/986d3857861b625ea18243fe9247474e.mp4", "stageId": 22, "replaceScore": 0, "topScore": 0, "reviewNum": 3, "img": "http://www.baidu.com/img/20150917/c22ce3c9047d8b9fee38b7c92751e224.jpg", "stageSort": 16, "noPass": false }, { "id": 300, "bid": 2043, "cardId": 273, "score": 5, "taskType": "health", "url": "http://www.baidu.com/baby/20150917/e075055ce7f57e11bc936481b35a8e74.mp4", "stageId": 22, "replaceScore": 0, "topScore": 0, "reviewNum": 3, "img": "http://www.baidu.com/img/20150917/b17aba0636279ed8683ba61c62daa4bd.jpg", "stageSort": 16, "noPass": false }, { "id": 299, "bid": 1389, "cardId": 3, "score": 0, "taskType": "health", "url": "http://www.baidu.com/img/20150917/37b0fe1f73e8bdec0b0dee2ae696cd05.jpg", "stageId": 1, "replaceScore": 0, "topScore": 0, "reviewNum": 3, "img": "", "stageSort": 1, "noPass": false }, { "id": 290, "bid": 29, "cardId": 287, "score": 0, "taskType": "active", "url": "http://www.baidu.com/baby/20150917/8079D13F1A5D9C1F2B68F8393CAD5540.mp4", "stageId": 24, "replaceScore": 0, "topScore": 0, "reviewNum": 4, "img": "http://www.baidu.com/img/20150917/596BC82D250717E3F415877FC9164421.jpg", "stageSort": 18, "noPass": false }, { "id": 289, "bid": 29, "cardId": 283, "score": 0, "taskType": "health", "url": "http://www.baidu.com/baby/20150917/B81A0923FCBF27A02CACF88537F86060.mp4", "stageId": 24, "replaceScore": 0, "topScore": 0, "reviewNum": 3, "img": "http://www.baidu.com/img/20150917/DDFE607FAAB56B0AF61862FDBA8523B5.jpg", "stageSort": 18, "noPass": false }, { "id": 288, "bid": 29, "cardId": 279, "score": 0, "taskType": "active", "url": "http://www.baidu.com/baby/20150917/479C420B141A62B3E6C4FD11D4F6DCC2.mp4", "stageId": 24, "replaceScore": 0, "topScore": 0, "reviewNum": 3, "img": "http://www.baidu.com/img/20150917/4CE715152AA42B73593650B7F785F732.jpg", "stageSort": 18, "noPass": false }, { "id": 287, "bid": 29, "cardId": 278, "score": 0, "taskType": "active", "url": "http://www.baidu.com/baby/20150917/4CCBEC3AF3FF455A616EE5891693DF9E.mp4", "stageId": 24, "replaceScore": 0, "topScore": 0, "reviewNum": 3, "img": "http://www.baidu.com/img/20150917/EAAD98391D7305F0429584AB881F11EC.jpg", "stageSort": 18, "noPass": false }, { "id": 285, "bid": 29, "cardId": 117, "score": 0, "taskType": "active", "url": "http://www.baidu.com/img/20150917/2991DC770972638080A9FD8418434430.jpg", "stageId": 24, "replaceScore": 0, "topScore": 0, "reviewNum": 3, "img": "http://www.baidu.com/img/20150917/2991DC770972638080A9FD8418434430.jpg", "stageSort": 18, "noPass": false } ] } }
下面开始:
贴代码
<c:forEach items="${taskpass}" var="task" varStatus="status"> <tr> <td>${task.id}</td> <td>${task.cardId}</td> <td> <c:if test="${fn:contains(task.url,'.mp4')}"> 视频 </c:if> <c:if test="${fn:contains(task.url,'.jpg')}"> 图片 </c:if> </td> <td> <c:if test="${task.noPass==true}"> 审核未通过 </c:if> <c:if test="${task.noPass==false}"> 审核通过 </c:if> </td> <td> <div class="visible-md visible-lg hidden-sm hidden-xs btn-group"> <button title="不通过" class="btn btn-xs btn-danger" data-taskId="${task.id}" id="deleStageBtn" ><i class="icon-ban-circle bigger-120"></i></button> <button title="通过" class="btn btn-xs btn-info" data-taskId="${task.id}" btntype="editStage"><i class="icon-check bigger-120"></i></button> </div> </td> </tr> </c:forEach>
就是这样。
时间: 2025-01-03 11:36:21