Java 表达式语言中的日历对象
如何获取表达式语言中的日、月、年和每个日历.XXXXXXX值Java 表达式语言中的日历对象,java,jsp,el,Java,Jsp,El,如何获取表达式语言中的日、月、年和每个日历.XXXXXXX值 ${object.calendarObject.MONTH} 不能直接使用calendar对象,可以使用以下getter方法为calendar对象创建包装器: public int getMonth(){ wrappedCalendar.get(Calendar.MONTH); } public int getDay(){ wrappedCalendar.get(Calendar.DAY_OF_MONTH); } p
${object.calendarObject.MONTH}
不能直接使用calendar对象,可以使用以下getter方法为calendar对象创建包装器:
public int getMonth(){
wrappedCalendar.get(Calendar.MONTH);
}
public int getDay(){
wrappedCalendar.get(Calendar.DAY_OF_MONTH);
}
public int getYear(){
wrappedCalendar.get(Calendar.YEAR);
}
...
所以你可以在你的表达语言上使用这样的东西:
${calWrapper.month}/${calWrapper.day}/${calWrapper.year}
不能直接使用calendar对象,可以使用以下getter方法为calendar对象创建包装器:
public int getMonth(){
wrappedCalendar.get(Calendar.MONTH);
}
public int getDay(){
wrappedCalendar.get(Calendar.DAY_OF_MONTH);
}
public int getYear(){
wrappedCalendar.get(Calendar.YEAR);
}
...
所以你可以在你的表达语言上使用这样的东西:
${calWrapper.month}/${calWrapper.day}/${calWrapper.year}
可以使用获取EL中的对象。您可以使用将日期对象格式化为JSP中的可读字符串。它通过pattern属性使用underhecover并支持其所有模式
在下面的示例中,为了简洁起见,我假设${cal}是日历。只要适用,就用${object.calendarObject}替换它
...
标准日期/时间:
标准日期:
日期:
月份:
年份:
年月日:
年月日:
到目前为止,这将产生类似于英语语言环境GMT+1的结果:
标准日期/时间:2011年7月6日10:34:17 PM
标准日期:2011年7月6日
日期:6
月份:7
年份:2011年
年月日:2011年7月6日
年月日:2011年6月7日
可以使用获取EL中的对象。您可以使用JSP将日期对象格式化为可读字符串。它通过pattern属性使用underhecover并支持其所有模式
在下面的示例中,为了简洁起见,我假设${cal}是日历。只要适用,就用${object.calendarObject}替换它
...
标准日期/时间:
标准日期:
日期:
月份:
年份:
年月日:
年月日:
到目前为止,这将产生类似于英语语言环境GMT+1的结果:
标准日期/时间:2011年7月6日晚上10:34:17
标准日期:2011年7月6日
日期:6
月份:7
年份:2011年
年月日:2011年7月6日
年月日:2011年6月7日
+1我知道这是一个毫无价值的评论,我完全可以删除它,但是@BalusC,你太棒了!每当我有关于无脚本JSP的问题时,我都会找你。+1我知道这是一个毫无价值的评论,我完全可以删除它,但是@BalusC,你太棒了!每当我有关于无脚本JSP的问题时,我都会找你。