1. 程式人生 > >jsp頁面傳遞date到java報錯

jsp頁面傳遞date到java報錯

jsp傳遞的是字串,在傳遞到java後臺處理時,在類裡先轉換一下即可!

    private Date createDate;

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(String createDate) throws ParseException {
    	if (StringUtils.isEmpty(createDate)) {
    		this.createDate = null;
	}else{
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		this.createDate = formatter.parse(createDate);
	}
    }