📄 orderform.java
字号:
package app05d.form;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.validator.DynaValidatorForm;
public final class OrderForm extends DynaValidatorForm {
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = super.validate(mapping, request);
if (errors==null)
errors = new ActionErrors();
String orderDateString = (String)this.get("orderDate");
if (!orderDateString.equals(null)) {
Date today = new Date();
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
try {
Date orderDate = dateFormat.parse(orderDateString);
if (orderDate.after(today)) {
errors.add("order", new ActionMessage("ruleError.orderDate"));
}
}
catch (ParseException ex) {
errors.add("order", new ActionMessage("ruleError.orderDate"));
}
}
return errors;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -