FooController.java:在JSP scriptlet中,如何訪問從Spring MVC ModelMap傳遞的java.util.Date值?
@RequestMapping(value = "/foo", method = RequestMethod.GET)
public final String foo(HttpServletRequest request, ModelMap model)
{
java.util.Date myDate = new java.util.Date();
model.addAttribute("myDate", myDate);
return "foo";
}
foo.jsp:
<%
java.util.Date myUtilDate = (java.util.Date)request.getParameter("myDate");
org.joda.time.DateTime myJodaDate = new org.joda.time.DateTime(myUtilDate);
%>
<joda:format value="${myJodaDate}" style="LL"/>
爲什麼在JSP腳本未能獲得被添加到ModelMap
在FooController
的myDate
價值?
EL語法(正如您所描述的)是訪問存儲在模型中的數據的「正確」方式 –