문제

I'm trying to do something like this:

<script type="text/javascript" src="<c:out value="${jsDirectory}javascript/StoreCommonUtilities.<tag:versionnumber/>js"/>"></script>

Where <tag:versionnumber/> is a custom JSP tag that works on its own. Currently, it just literally prints out "<tag:versionnumber/>". Any help is appreciated.

도움이 되었습니까?

해결책

<c:out> is used to escape special HTML characters (<, >, &, ' and "). I sure hope you don't have those characters in the jsDirectory attribute. So there's no reason to use <c:out>:

<script type="text/javascript" src="${jsDirectory}javascript/StoreCommonUtilities.<tag:versionnumber/>js"></script>

That said, if you want to use the value of <tag:versionnumber> in other tag attributes, you should create an EL function instead of a tag, or make it possible to store the result in a page-scope attribute, as <c:set> does:

<tag:versionnumber var="version"/>
<c:out value="${version}"/>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top