JSP中Custom标记中的问题

时间:2021-11-07 19:00:07

Hi i have a 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"))%>'>

It is working fine except for helpURL='<%=((Map)request.getAttribute("constants")).get("WEB_CONTEXT").toString()%>/web/ABCGlossary.jsp'

它的工作正常,除了helpURL ='<%=((Map)request.getAttribute(“constants”))。get(“WEB_CONTEXT”)。toString()%> / web / ABCGlossary.jsp'

it is not getting translated in jsp it is giving output some like %=((Map)request.getAttribute("constants")).get("WEB_CONTEXT").toString()%>/web/ABCGlossary.jsp

它没有在jsp中被翻译它给输出一些像%=((Map)request.getAttribute(“constants”))。get(“WEB_CONTEXT”)。toString()%> / web / ABCGlossary.jsp

Can you please help me what is the problem it have enable rtexprvalue

你能帮我解决它启用rtexprvalue的问题吗?

1 个解决方案

#1


This is likely down to the way you're mixing script expressions and literals, you're confusing the JSp compiler.

这可能取决于你混合脚本表达式和文字的方式,你会混淆JSp编译器。

If this is JSP 2.0 or higher, you can make this much more readable by using EL expressions rather than scriptlets, like this:

如果这是JSP 2.0或更高版本,则可以通过使用EL表达式而不是scriptlet使这更具可读性,如下所示:

helpURL="${requestScope.constants.WEB_CONTEXT + '/web/ABCGlossary.jsp'}"

Failing that, just make your life easier by assigning the value of the helpURL to a seperate variable and then referring to it in your tag

如果做不到这一点,只需将helpURL的值分配给单独的变量,然后在标签中引用它,就可以让您的生活更轻松

<% String helpURL = ((Map)request.getAttribute("constants")).get("WEB_CONTEXT").toString() + '/web/ABCGlossary.jsp' %>

helpURL='<%= helpURL  %>'

#1


This is likely down to the way you're mixing script expressions and literals, you're confusing the JSp compiler.

这可能取决于你混合脚本表达式和文字的方式,你会混淆JSp编译器。

If this is JSP 2.0 or higher, you can make this much more readable by using EL expressions rather than scriptlets, like this:

如果这是JSP 2.0或更高版本,则可以通过使用EL表达式而不是scriptlet使这更具可读性,如下所示:

helpURL="${requestScope.constants.WEB_CONTEXT + '/web/ABCGlossary.jsp'}"

Failing that, just make your life easier by assigning the value of the helpURL to a seperate variable and then referring to it in your tag

如果做不到这一点,只需将helpURL的值分配给单独的变量,然后在标签中引用它,就可以让您的生活更轻松

<% String helpURL = ((Map)request.getAttribute("constants")).get("WEB_CONTEXT").toString() + '/web/ABCGlossary.jsp' %>

helpURL='<%= helpURL  %>'