例如在windows下:
Test.action中:
private Date expiredDate;
public Date getExpiredDate() {
return expiredDate;
}
public void setExpiredDate(Date expiredDate) {
this.expiredDate = expiredDate;
}
/**
* 添加
* @return
*/
public String addNewsOrNotice(){
SwNotice notice = new SwNotice();
notice.setExpiredDate(expiredDate);
······
noticeBiz.save(notice);
return "operation";
}
public class SwNotice implements java.io.Serializable {
// Fields
private Date expiredDate;
······
/** default constructor */
public SwNotice() {
}
/** full constructor */
public SwNotice(Date expiredDate,······) {
this.expiredDate = expiredDate;
······
}
public Date getExpiredDate() {
return this.expiredDate;
}
public void setExpiredDate(Date expiredDate) {
this.expiredDate = expiredDate;
}
······
}
Linux下:
Test.action中:
private String expiredDate;
public String getExpiredDate() {
return expiredDate;
}
public void setExpiredDate(String expiredDate) {
this.expiredDate = expiredDate;
}
/**
* 添加
* @return
*/
public String addNewsOrNotice(){
SwNotice notice = new SwNotice();
try {
notice.setExpiredDate(new SimpleDateFormat("yyyy-MM-dd").parse(expiredDate));
} catch (ParseException e) {
e.printStackTrace();
}
······
noticeBiz.save(notice);
return "operation";
}
public class SwNotice implements java.io.Serializable {
// Fields
private Date expiredDate;
······
/** default constructor */
public SwNotice() {
}
/** full constructor */
public SwNotice(Date expiredDate,······) {
this.expiredDate = expiredDate;
······
}
public Date getExpiredDate() {
return this.expiredDate;
}
public void setExpiredDate(Date expiredDate) {
this.expiredDate = expiredDate;
}
······
}