开发者

Exception getting JodaTime JSP Taglibs working

I'm trying to get the JodaTime taglib working in my Spring 3 MVC app.

Per the website I should be able to put this in my jsp page and it should work.

<%@taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %>
<% pageContext.setAttribute("now", new org.joda.time.DateTime()); %>
<joda:format value="${now}" style="SM" />

I'm getting this exception however:

org.apache.jasper.JasperException: /WEB-INF/jsp/reports/../taglibs.jspf(7,66) PWC6188: The absolute uri: http://www.joda.org/joda/time/tags cannot be resolved in either web.xml or the jar files deployed with this application

I'm running Glassfish 3.0.1. Servlet version 2.4 is declared in my web.xml file. JSP 2.1. JSTL 1.1.

Addition: I've added joda-time-jsptag-1.0.2.jar to my WEB-INF/lib directory. I als开发者_如何学编程o have joda-time-1.6.1.jar on the same lib dir.

Does the taglib uri need to be valid? When I try and visit http://www.joda.org/joda/time/tags in my browser it redirects to the sourceforge page. Maybe I just need an updated URI link?

Any takers?


The taglib URI does not necessarily point to a real web resource. The taglib URI should match the <uri> declaration in any of the .tld files which is present in the classpath.

Given this fact, there are two possible causes:

  1. The TLD file (at least, the JAR file containing it) is not in the classpath at all.
  2. The TLD file did declare a different URI.

I don't have experience with JodaTime tags, so I can't tell from top of head if this (mis)behaviour is correct. Best what I can suggest is to extract the JAR file containing the TLD files using some ZIP tool yourself and then read the actual <uri> in the .tld file in the META-INF folder of the JAR.

If that turns out to be the same, then you've likely got a problem with the classpath or build settings. Are the JAR files really present in the (expanded) WAR file on the running webapp environment?


Unrelated to the concrete problem, Servlet 2.4 implies JSP 2.0, not JSP 2.1. Besides, why would you be using Servlet 2.4 instead of 2.5 or even 3.0? Glassfish 3 supports Servlet 3.0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜