首先引入joda-time包。maven的dependency:
<dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>2.4</version> </dependency>
在Controller代碼里:
public String testMethod(@RequestParam @DateTimeFormat(pattern="yyyy-MM-dd") Date testdate){ System.out.println(testDate);}注意用pattern來規(guī)定日期的格式。
測試的url:
?testdate=2014-09-04
新聞熱點(diǎn)
疑難解答
圖片精選