避免在 JSP 標籤中以巢狀方式放置單引號或雙引號

當 JSP 標籤中以巢狀方式將單引號放置在單引號內或將雙引號放置在雙引號內,此規則會將該 JSP 標籤標示出來。

範例 1:
<c:if test="<%=(link.indexOf(':') == -1)%>" >

在此範例中, test 屬性包含字元順序 ':' 巢狀內嵌在外部單引號中 '<%=(link.indexOf(':') == -1)%>' 。此規則將標示此範例。

自動修正功能會轉換嵌套的引號。 在範例中,引號 周圍的 ':' 已跳出。

範例:
<c:if test="<%=(link.indexOf(\':\') == -1)%>" >

當 JSP 標籤中出現巢狀引號時,可能導致類似下列範例的錯誤訊息:

Error Message:JSPG0048E: Page failed to validate using taglib validator for ... : org.xml.sax.SAXParseException: Attribute name "jsp:id" associated with an element type "c:if" must be followed by the " = " character.
Root Cause:com.ibm.ws.jsp.translator.JspTranslationException: JSPG0048E: Page failed to validate using taglib validator for...

如需相關資訊,請參閱: