[英]Problem in Custom tag in JSP
嗨,我在JSP中有一個自定義標簽
<dc:drawMultiSelect
availableLabel='<%=request.getAttribute("availableCoreColumn").toString()%>'
selectedLabel='<%=request.getAttribute("selectedCoreColumns").toString()%>'
availableCName="selectCol"
selectedCName="selectedCol"
availableCId="select1"
selectedCId="select2"
sort="off"
columnHelp="on"
helpURL='<%=((Map)request.getAttribute("constants")).get("WEB_CONTEXT").toString()%>/web/ABCGlossary.jsp'
selectSize="8"
selectWidth="250px"
selectMultiple="true"
availableMap='<%=((HashMap) request.getAttribute("availableColMap"))%>'
selectedMap='<%=((HashMap) request.getAttribute("selectedColMap"))%>'>
除helpURL ='<%=(((Map)request.getAttribute(“ constants”))。get(“ WEB_CONTEXT”)。toString()%> / web / ABCGlossary.jsp'之外,它都正常運行
它沒有在jsp中得到翻譯,而是輸出%=((Map)request.getAttribute(“ constants”))。get(“ WEB_CONTEXT”)。toString()%> / web / ABCGlossary.jsp
能否請我幫我啟用rtexprvalue有什么問題
這很可能是混合腳本表達式和文字的方式,這使JSp編譯器感到困惑。
如果是JSP 2.0或更高版本,則可以使用EL表達式而不是scriptlet使其更具可讀性,如下所示:
helpURL="${requestScope.constants.WEB_CONTEXT + '/web/ABCGlossary.jsp'}"
失敗的話,只需將helpURL的值分配給單獨的變量,然后在標記中引用它,就可以使您的生活更輕松
<% String helpURL = ((Map)request.getAttribute("constants")).get("WEB_CONTEXT").toString() + '/web/ABCGlossary.jsp' %>
helpURL='<%= helpURL %>'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.