前端的IF語句很實用


前端的if語句可以用於權限的解決方案

需求:chebox選擇按鈕有值傳入的時候,顯示的是值的數據,沒有值或者新建的數據顯示頁面上的值。

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

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM