【发布时间】:2012-09-28 13:52:21
【问题描述】:
我必须得到一个JSP的真实路径,而且我必须用Expression Language来做。然后,我将路径发送到 TagLib。
我发现:
<mytag:getstats rtexprvalue="${pageContext.request.contextPath}"/>
但我在 rtexprvalue 上有一个警告说它是 undefind 和另一个在 EL 中:The declared exception IOException is not actually thrown by the method _elExpression15() from type
__2F_PrizeWheel_2F_WebContent_2F_stats_2E_jsp。
我的 .tld 中的 TagLib 声明如下:
<tag>
<name>getstats</name>
<tag-class>connector.FileConnector</tag-class>
<attribute>
<name>name</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
也许我做错了。所以如果你有更好的解决方案,我很感兴趣:)
【问题讨论】:
-
为什么需要一个属性来获取
contextPath?您可以使用pageContext获取ServletRequest,然后将其转换为HttpServletRequest。