Java 设置表达式时出错
由于某些原因,我收到以下错误消息:Java 设置表达式时出错,java,jsp,struts2,type-conversion,el,Java,Jsp,Struts2,Type Conversion,El,由于某些原因,我收到以下错误消息: Developer Notification (set struts.devMode to false to disable this message): Unexpected Exception caught setting 'claimForm.payableEvents[1].totalHours' on 'class com.somedomain.application.action.claimreimbursement.ProcessSaveClai
Developer Notification (set struts.devMode to false to disable this message): Unexpected Exception caught setting 'claimForm.payableEvents[1].totalHours' on 'class com.somedomain.application.action.claimreimbursement.ProcessSaveClaimFormAction: Error setting expression 'claimForm.payableEvents[1].totalHours' with value '[Ljava.lang.String;@54f242c1'
Developer Notification (set struts.devMode to false to disable this message): Unexpected Exception caught setting 'claimForm.payableEvents[2].totalHours' on 'class com.somedomain.application.action.claimreimbursement.ProcessSaveClaimFormAction: Error setting expression 'claimForm.payableEvents[2].totalHours' with value '[Ljava.lang.String;@1ff32b5d'
Developer Notification (set struts.devMode to false to disable this message): Unexpected Exception caught setting 'claimForm.payableEvents[1].totalHours' on 'class com.somedomain.application.action.claimreimbursement.ProcessSaveClaimFormAction: Error setting expression 'claimForm.payableEvents[1].totalHours' with value '[Ljava.lang.String;@54f242c1'
Developer Notification (set struts.devMode to false to disable this message): Unexpected Exception caught setting 'claimForm.payableEvents[2].totalHours' on 'class com.somedomain.application.action.claimreimbursement.ProcessSaveClaimFormAction: Error setting expression 'claimForm.payableEvents[2].totalHours' with value '[Ljava.lang.String;@1ff32b5d'
根据关于缺少参数的警告标题下的文章,据我所知,参数设置器存在问题
我已经回去检查了,我确实有一个为参数正确命名的setter
以下是我的java类的精简版本:
public class ClaimWizardPayableEventAjaxAction{
private ClaimForm claimForm;
public void setClaimForm(ClaimForm claimForm) {
this.claimForm = claimForm;
}
}
public class ClaimForm{
private List<PayableEvent> payableEvents;
public void setPayableEvents(List<PayableEvent> payableEvents) {
this.payableEvents = payableEvents;
}
}
public class PayableEvent{
private BigDecimal totalHours;
public void setTotalHours(BigDecimal totalHours) {
this.totalHours = totalHours;
}
}
公共类索赔向导PayableEventAjaxAction{
私人诉讼请求书;
公共无效诉讼请求书(诉讼请求书){
this.claimForm=索赔形式;
}
}
公共类索赔表{
私人列表可支付事件;
public void setPayableEvents(列出payableEvents){
this.payableEvents=payableEvents;
}
}
公共类可支付事件{
私人时间;
公共无效setTotalHours(BigDecimal totalHours){
this.totalHours=totalHours;
}
}
使用c:forEach:
至于我试过什么?我已经检查了我的拼写,没有发现任何不一致之处。我已经检查过了,它确实在保存值。这与将其转换为大的
bigdecime
有关吗?这是由于类型转换,因为您没有使用Struts标记,值被转换为字符串并返回到BigInteger
。如果您不喜欢收到这样的警告,您可以关闭struts.devMode
。警告很好:-)我们确实还在开发中。只是我们直到最近才看到这样的警告。(其中一个开发人员升级了我们正在使用的库)。我试图确认没有什么不好的事情发生。确实没有什么不好的事情,但有些事情不好,这就是为什么这些警告。在开始使用Struts时,您可以尝试更改代码以删除此类警告。为了节省开发时间,devMode应该关闭。你也有getter吗?是的,我有getter。只是把它们从示例中清除了。所有其他属性都已设置且没有问题。