开发者

Error formatting a DateTime object with joda time's JSP tag

I have a problem when passing a DateTime object to my JSP, the joda:format tag takes the attribute value as a String.

Here is my JSP:

<joda:format value="${next.date}" style="FF" />

next is an object with the following code:

/**
 * @return the date
 */
public DateTime getDate() {
    return date;
}

And here is my Exception:

javax.servlet.jsp.JspException: value attribute of format tag must be a ReadableInstant or ReadablePartial, was: java.lang.String

I've even tried doing this 开发者_如何学JAVAdirectly from the jsp to no avail:

<% pageContext.setAttribute("now", new org.joda.time.DateTime()); %>
<joda:format value="${now}" style="FF" />

Don't understand why I get this exception, can you help me ?


This exception means that "${...}" is parsed like normal String, so check if your application using EL expressions. From documentation:

you should ensure that your application is using servlet specification 2.4. This is usually controlled by the web.xml file. If you do not do this then EL expressions will not work as expected.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜