繁体   English   中英

表单未在sql.date的控制器上赋予值

[英]Form is not giving value on controller for sql.date

表单未在sql.date控制器上赋予价值,我正在使用spring,以下是表单的代码

 <form:input path="regDateFrom" cssClass="txt-field-date" id="txt_reg_form" readonly="true" />

和我的控制器是一样的。

 protected ModelAndView processFormSubmission(HttpServletRequest request,
        HttpServletResponse response, Object command, BindException errors)
        throws Exception {
    String param_error = null;
    VehicleSearch vehicleSampling = (VehicleSearch) command;
    System.out.println(vehicleSampling.getRegDateFrom());

在印刷品上它为null

你需要

@InitBinder
    public void initBinder(WebDataBinder binder) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
        dateFormat.setLenient(false);
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    }

而不是“ sql.date”使用“ util.date”

也可以尝试删除属性“只读”

我猜您需要删除“ ReadOnly = true”,如果将readOnly设置为true,则该值将不会与请求一起传递。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM