jstl根据字符串进行判断

惯例:

我是温浩然:

先说需求:

调用接口,传过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

jstl根据字符串进行判断的相关文章

arraylist-求大神帮看下代码,怎么做才能接收自己输入的字符串进行判断呢?

问题描述 求大神帮看下代码,怎么做才能接收自己输入的字符串进行判断呢? public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("请输入你要查询出现单词或字母次数句子"); ArrayList<Object> arrayList = new ArrayList<Object>(); String f = s.nextLine()

java字符串 怎么判断字符串中是否全是数字只有一个小数点呢?

问题描述 java字符串 怎么判断字符串中是否全是数字只有一个小数点呢? 怎么判断字符串中是否全是数字和只有一个小数点呢?用正则和非正则 解决方案 s.split(".").length() == 2 解决方案二: 正则的方式 ([^.]*.[^.]*)+ 解决方案三: 强转下不就行了么?能转就说明是,不能就不是 String abc = "23232.222"; try { Double db = Double.valueOf(abc); System.out.p

PHP 字符串包含判断

遇到了这个问题.记录一下.用strpos查找字符串来进行字符串包含判断. 1 <?php 2 //$res = strpos("hello", "hx"); 3 $res = strpos("hello", "he"); 4 if ($res !== false){ 5 echo "find OK, pos:$res\n"; 6 } 7 else { 8 echo "find failed,

PHP 字符串长度判断效率更高的方法

 在php里当需要判断一个字符串长度时,我们首先想到的是strlen()函数,不错,strlen()返回的就是字符串的长度,这样使用没有任何问题.不过,如果要从php程序优化的角度来看,使用strlen()判断字符串长度未免是最好的写法 有经验的程序员发现,php判断字符串长度,使用isset()在速度上比strlen()更快,执行效率更高. 即:    代码如下: $str = 'aaaaaa'; if(strlen($str) > 6) VS if(!isset($str{6})   用例子

关于字符串,判断一个值是否在字符串里面

问题描述 现在有一个问题...我取得了一个字符串为1,2,3,4,5,6我要判断4是否在里面的语句?有知道的告诉我一下 解决方案 解决方案二:我相信下面会有许多人误解题目解决方案三:引用1楼nazhawenxi的回复: 我相信下面会有许多人误解题目 我取得一个字符串,我要判断一个值是否在字符串里面解决方案四:参考javaAPI:publicintindexOf(Stringstr)返回指定子字符串在此字符串中第一次出现处的索引.返回的整数是this.startsWith(str,k)为true的

使用C语言提取子字符串及判断对称子字符串最大长度_C 语言

先来看一个使用C语言从字符串中提取子字符串的基本方法总结: #include <stdio.h> /*处理中文字符*/ /*遍历字符串,非ASCII字符读取2个字节,ASCII读取一个字节,获取字符串长度*/ int StrLenU(const char* string) { int len = 0 ; const char* p = string; while(*p++ != '\0') { if(*p > 0x80 || *p < 0) { p++; } len++; } re

Mysql字符串字段判断是否包含某个字符串的2种方法

  假设有个表: 代码如下: CREATE TABLE users(id int(6) NOT NULL AUTO_INCREMENT,PRIMARY KEY (id),user_name VARCHAR(20) NOT NULL,emails VARCHAR(50) NOT NULL); 初始化表,并添加些记录. 代码如下: truncate table users INSERT INTO users(user_name, emails) VALUES('小张','a@email.com,b@

Mysql字符串字段判断是否包含某个字符串的2种方法_Mysql

假设有个表: 复制代码 代码如下: CREATE TABLE users(id int(6) NOT NULL AUTO_INCREMENT,PRIMARY KEY (id),user_name VARCHAR(20) NOT NULL,emails VARCHAR(50) NOT NULL); 初始化表,并添加些记录. 复制代码 代码如下: truncate table users INSERT INTO users(user_name, emails) VALUES('小张','a@emai

shell字符串比较判断是否为数字_linux shell

二元比较操作符,比较变量或者比较数字.注意数字与字符串的区别. 整数比较 -eq 等于,如:if [ "$a" -eq "$b" ] -ne 不等于,如:if [ "$a" -ne "$b" ] -gt 大于,如:if [ "$a" -gt "$b" ] -ge 大于等于,如:if [ "$a" -ge "$b" ] -lt 小于,如:if [ &