如何使fmt:formatDate适用于form:input [英] How to make fmt:formatDate work for form:input

查看:79
本文介绍了如何使fmt:formatDate适用于form:input的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jstl循环,我想格式化form:input的日期.我已经尝试了一些我在线上喜欢的建议的多种排列方式,但我无法使它起作用..有人可以看看吗?

I have a jstl loop and I want to format the date of a form:input. I have tried many permutations of some of the suggestions that I've fond online but I just cannot get it to work.. Can someone please have a look?

我已经包含了完整的上下文循环,但是问题出在最后一个<td></td>块中.

I've included the full loop for context but the problem lies in the last <td></td> block.

<c:forEach items="${valueTransactionsModel.transactions}" var="transaction" varStatus="loopStatus">

                        <tr class="${loopStatus.index % 2 == 0 ? 'even' : 'odd'}">
                            <spring:message code="valueTransactions.transactionType" var="transactionTypeLbl" />
                            <tags:dropdown id="transactionTypeId${loopStatus.index}" path="transactions['${loopStatus.index}'].valueTransactionType.id" 
                                fieldName="${transactionTypeLbl}" classStyle="mandatory" items="${transactionTypes}" itemLabel="value"/>
                        </tr>
                        <tr class="${loopStatus.index % 2 == 0 ? 'even' : 'odd'}">
                            <spring:message code="valueTransactions.transactionAmount" var="valueTransactionAmountLbl${loopStatus.index}" />
                            <tags:input id="transactionAmountId${loopStatus.index}" 
                                path="transactions['${loopStatus.index}'].valueTransactionAmount"
                                fieldName="valueTransactionAmountLbl${loopStatus.index}"
                                maxlength="30" classStyle="mandatory" />
                            <spring:message code="valueTransactions.transactionDate"
                                var="valueTransactionDateLbl${loopStatus.index}" />
                            <td>
                                <form:input type="text" path="transactions['${loopStatus.index}'].valueTransactionDate" cssClass="mandatory" value="<fmt:formatDate value="transactions['${loopStatus.index}'].valueTransactionDate"  type="date" pattern="yyyy-MM-dd"/>" />
                            </td>
                        </tr> 


            </c:forEach>

我最近的问题是:

JSPG0055E:无法通过名称[transactions []值[$ {loopStatus.index}]创建xml属性

JSPG0055E: Unable to create an xml attribute from name [transactions[] value [${loopStatus.index}]

推荐答案

您不能在另一个JSP标记的属性中使用JSP标记.将日期格式的结果存储在page属性中,并使用此page属性(就像对Java中的变量所做的那样):

You can't use a JSP tag in an attribute of another JSP tag. STore the result of the date formatting in a page attribute, and use this page attribute (as you would do with a variable in Java):

<fmt:formatDate value="transactions['${loopStatus.index}'].valueTransactionDate"  
                type="date" 
                pattern="yyyy-MM-dd"
                var="theFormattedDate" />
<form:input type="text" path="..." value="${theFormattedDate}"/>

这篇关于如何使fmt:formatDate适用于form:input的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆