前端的IF语句很实用

前端的if语句可以用于权限的解决方案

需求:chebox选择按钮有值传入的时候,显示的是值的数据,没有值或者新建的数据显示页面上的值。

	<div class="controls">
			    是
				<form:radiobutton   path="defaultSelection" name="gender" value="1" htmlEscape="false" style="10px;" maxlength="125" class="required"/>
			    否<c:if test="${empty ocDevopsScore.defaultSelection}">
			   <form:radiobutton    path="defaultSelection" name="gender" value="0"  checked="checked" htmlEscape="false" style="10px;" maxlength="125" class="required"/>
				 </c:if>
				 <c:if test="${not empty ocDevopsScore.defaultSelection}">
			   <form:radiobutton    path="defaultSelection" name="gender" value="0" htmlEscape="false" style="10px;" maxlength="125" class="required"/>
				 </c:if>
			</div>
		

  

判断相等执行的语句

 <c:if test="${dict.level == 5}">
  <a href="${ctx}/oc/devopsscore/list?devopsTypeId=${dict.id}">[scoreList]</a>
  </c:if>

可以这样写判断 进行跳框提示

<a href="${ctx}/oc/scope/delete?id=${dict.id}&type=${dict.type}" onclick="return confirmx('Do you want to delete the scope?', this.href)">[delete]</a>

  

需求:判断登录的user是否有权限修改,自己只能修改自己的数据,超级管理院员就能修改全部的数据。

<c:choose>		
	    					<c:when test="${fns:getUser().id eq dict.createBy.id}">
	    					<a href="${ctx}/ito/projectinfo/delete?id=${dict.id}" onclick="return confirm('Do you want to delete the record?', this.href)">[delete]</a>
	    					</c:when>
	    					<c:otherwise>
		    					<shiro:hasAnyRoles name="system">  
		    					<a href="${ctx}/oc/projectinfo/delete?id=${dict.id}" onclick="return confirm('Do you want to delete the record?', this.href)">[delete]</a>
		    					</shiro:hasAnyRoles>
	    					</c:otherwise>
	    				</c:choose>

  

原文地址:https://www.cnblogs.com/jiajialeps/p/10182602.html