Unterminated C: out Tag for ternary operator

I set a session area object in my session, and I want to add a disabled attribute to one of my buttons using the JSTL Ternary operator.

GetPermission is a privilege map for the current login user, but I'm not sure why I encountered an unterminated c:out tag error in my JSP when it goes to that JSP.

 <button type="button" id="addButton" <c:out value="${empty sessionScope.voUserInfo.getPermission.ADD_ITEM ? "disabled='disabled'" : ''}"/> > ADD </button> 
+4
source share
1 answer

The first double quotation mark inside the value violates the value too soon. You should use singlequotes only to indicate strings in EL, not double letters. You should use doublequotes only to indicate HTML attribute values.

 <button id="add" <c:out value="${empty var ? 'disabled="disabled"' : ''}"/>> 

(please do not pay attention to the syntax of the Stackoverflow code syntax, it does not recognize the correct / EL tags, this is legally permissible)

Or, when you are on JSP 2.0 or later, you can simply leave this c:out for as long as there is no risk to XSS (this is not the case because you are printing a server-controlled value).

 <button id="add" ${empty var ? 'disabled="disabled"' : ''}> 
+7
source

All Articles