繁体   English   中英

如何将隐藏日期值从一个JSTL传递到另一个?

[英]How to pass hidden date value from one JSTL to another?

我收到HTTP 400问题(语法错误)

<input type="hidden" id="_orderDate_id" name="orderDate" value="${orderDate}"/>

但是删除此输入元素后,一切都很好

但是我们真的需要格式化这种日期字段吗?

这是控制器中使用的日期格式活页夹

@InitBinder
public void registerDateBinder(WebDataBinder binder) {
    DateFormat printFormat = new SimpleDateFormat(DateTimeFormat.patternForStyle("S-", LocaleContextHolder.getLocale())); // format for data on the UI
    printFormat.setLenient(false);
    DateFormat sortFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy"); // format for data get back from UI
    sortFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new ExpandableCustomDateEditor(printFormat, Arrays.asList(printFormat, sortFormat), true));
}

只是为了增加对问题的评论,请检查第一个JSP的来源,以查看隐藏值是否确实已呈现为存储在orderDate中的日期,或者您实际上是在看到$ {orderDate}。 视图源应该向您显示结果,因此,如果所有内容确实在渲染并且可以正常工作,那么您应该看到一个日期。

暂无
暂无

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

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