【发布时间】:2018-09-22 21:50:27
【问题描述】:
我的网站上有一个表单,它询问用户信息(如姓名、地址等),主要是字符串、一个 int 和一个 ArrayList。我使用 Spring webflow 主要是为了允许查看视图状态,以便用户可以返回并编辑字段,并且因为我也使用了一些其他表单,所以我试图保持我的代码一致。
我遇到的问题是我的 Arraylist。我希望用户最多可以添加 10 位医生(姓名、保单编号、专业),但我不断收到 BeanException 和错误消息,表明我的列表为空。当我点击评论按钮进入下一个视图时,页面将重新加载并抛出我在底部发布的错误。
这是我的 spring webflow 的一部分: 在视图 PracticeReviewRequest 我用一个新的 Arraylist 实例化我的 arrayList
<set name="flowScope.pageDescription" value="'Please complete the form below to submit your request for a practice review.'"/>
</on-start>
<view-state id="practiceReviewRequest" view="/components/risk/practiceReview" model="practiceReviewForm">
<on-entry>
<set name="flowScope.practiceReviewForm.physicians" value="new java.util.ArrayList()"/>
</on-entry>
<transition on="review" to="practiceReviewRequestReview"/>
<transition on-exception="org.tmlt.data.dao.DataAccessException" to="practiceReviewRequest">
<set name="flowScope.exception" value="rootCauseException"/>
</transition>
</view-state>
<view-state id="practiceReviewRequestReview" view="/components/risk/email">
<transition on="submit" to="practiceReviewRequestSubmit"/>
<transition on-exception="org.tmlt.data.dao.DataAccessException" to="practiceReviewRequest">
<set name="flowScope.exception" value="rootCauseException"/>
</transition>
</view-state>
这是我的 Object practiceReviewRequest 的艺术
@XmlAccessorType(XmlAccessType.FIELD) 公共类 PracticeReviewRequestImpl 实现 IPracticeReviewRequest, Serializable {
private static final long serialVersionUID = 1L;
private String submitName;
private String policyType;
private String groupName;
private String policyNumber;
private int physNum;
private List<IPracticeReviewRequest> physicians = new ArrayList<>(15);
@Override
public List<IPracticeReviewRequest> getPhysicians() {
return physicians;
}
@Override
public void setPhysicians(List<IPracticeReviewRequest> physicians) {
this.physicians = physicians;
}
@Override
public int getPhysNum() {
return physNum;
}
...
这是我的医师对象: 公共类 PracticeReviewRequestPhysicianImpl 实现 IPracticeReviewRequestPhysician, Serializable {
private static final long serialVersionUID = 1L;
private String name;
private String policyNumber;
private String specialty;
@Override
public String getName() {
return name;
}
@Override
public String getPolicyNumber() {
return policyNumber;
}
@Override
public String getSpecialty() {
return specialty;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public void setPolicyNumber(String policyNumber) {
this.policyNumber = policyNumber;
}
@Override
public void setSpecialty(String specialty) {
this.specialty = specialty;
}
...
这是我的 .ftl 的一部分(为了解决这个问题,我只硬编码一个外业医师 [0].name 而不是使用我的 JS 函数循环医师 [i].name 等...)(这都在一个表单标签中,包含隐藏的输入类型 flowExecutionKey)
这是我在我的 tomcat 中看到的错误消息。
2018-04-12 11:00:15,916 调试 springframework.binding.mapping.impl.DefaultMapper:源 [org.springframework.webflow.core.collection.LocalParameterMap] 和目标 [org.tmlt.data. model.impl.PracticeReviewRequestImpl]
2018-04-12 11:00:15,923 调试pringframework.binding.mapping.impl.DefaultMapping:添加映射结果[TargetAccessError@c60ad7映射=参数:'执行'->执行,代码='propertyNotFound',错误=真,错误原因= org.springframework.binding.expression.PropertyNotFoundException:找不到属性,originalValue = 'e7s1',mappedValue = [null]]
2018-04-12 11:00:15,924 调试 pringframework.binding.mapping.impl.DefaultMapping:添加映射结果 [Success@122d6f5 映射 = 参数:'submitName' -> submitName,代码 = '成功',错误 = false,originalValue ='测试',mappedValue ='测试']
2018-04-12 11:00:15,924 DEBUG pringframework.binding.mapping.impl.DefaultMapping:添加映射结果 [Success@6ced27 mapping = parameter:'policyType' -> policyType, code = 'success', error = false, originalValue ='是',mappedValue ='是']
2018-04-12 11:00:15,925 调试pringframework.binding.mapping.impl.DefaultMapping:添加映射结果[成功@769c4映射=参数:'组名'->组名,代码='成功',错误=假,原始值='Tset',映射值 ='Tset']
2018-04-12 11:00:15,925 调试pringframework.binding.mapping.impl.DefaultMapping:添加映射结果[成功@ae3690映射=参数:'policyNumber'-> policyNumber,代码='成功',错误= false,originalValue = 'SEt1',映射值 = 'SEt1']
2018-04-12 11:00:15,925 调试pringframework.binding.mapping.impl.DefaultMapping:添加映射结果[成功@1ded18e映射=参数:'physNum'-> physNum,代码='成功',错误=假,原始值='1',映射值 ='1']
2018-04-12 11:00:15,925 调试 pringframework.binding.mapping.impl.DefaultMapping:添加映射结果 [TargetAccessError@1c1147 映射 = 参数:'physicians[0].name'->医师[0].name,代码='evaluationException',error = true,errorCause = org.springframework.binding.expression.EvaluationException:在上下文 [class org.tmlt.data.model.impl .PracticeReviewRequestImpl] 到 [Ttest], originalValue = 'Ttest', mappedValue = [null]]
2018-04-12 11:00:15,926 调试 pringframework.binding.mapping.impl.DefaultMapping:添加映射结果 [TargetAccessError@1461909 mapping = null -> eventId_review,code = 'propertyNotFound',error = true,errorCause = org.springframework .binding.expression.PropertyNotFoundException:找不到属性,originalValue = [null],mappedValue =enter code here [null]]
2018-04-12 11:00:15,927 调试 springframework.binding.mapping.impl.DefaultMapper:完成源 [org.springframework.webflow.core.collection.LocalParameterMap] 和目标 [org.tmlt.data.model.impl 之间的映射.PracticeReviewRequestImpl];总映射 = 8;总错误 = 3
2018-04-12 11:00:15,927 调试 g.springframework.webflow.mvc.view.AbstractMvcView:模型绑定导致错误;将错误消息添加到上下文
2018-04-12 11:00:15,931 调试 ingframework.binding.message.DefaultMessageContext:使用 [DefaultMessageResolver@dc00ab 源 = 'physicians[0].name',严重性 = 错误,代码 = 数组 ['practiceReviewForm.physicians[ 0].name.evaluationException', 'practiceReviewForm.physicians.name.evaluationException', 'physicians[0].name.evaluationException', 'physicians.name.evaluationException', 'name.evaluationException', 'evaluationException'], args =数组[[MessageBuilder.ResolvableArgument@cd5bdf arg = 'physicians[0].name']], defaultText = 'evaluationException on doctors[0].name']
2018-04-12 11:00:15,932 DEBUG ingframework.binding.message.DefaultMessageContext:添加已解决的消息 [Message@17402e3 source = 'physicians[0].name',severity = ERROR,text ='evaluationException on doctors[0] 。姓名']
2018-04-12 11:00:15,932 调试 g.springframework.webflow.mvc.view.AbstractMvcView:验证模型
2018-04-12 11:00:15,934 调试 org.springframework.webflow.engine.ViewState:渲染 + [ServletMvcView@152a4e0 视图 = info.magnolia.module.blossom.view.TemplateView:名称“/components/risk/practiceReview” ; URL [/MyTMLT/templates/components/mytmlt/myTMLTComponent.ftl]]
2018-04-12 11:00:15,934 调试 org.springframework.webflow.engine.ViewState:Flash 范围 = map[[empty]]
2018-04-12 11:00:15,934 调试 org.springframework.webflow.engine.ViewState:Messages = [DefaultMessageContext@19f94a4 sourceMessages = map[[null] -> list[[empty]],'physicians[0].name ' -> list[[Message@17402e3 source ='physicians[0].name',severity = ERROR,text ='evaluationException on doctors[0].name']]]]
2018-04-12 11:00:15,935 调试 g.springframework.webflow.mvc.view.AbstractMvcView:渲染 MVC [info.magnolia.module.blossom.view.TemplateView:名称“/components/risk/practiceReview”; URL [/MyTMLT/templates/components/mytmlt/myTMLTComponent.ftl]] 与模型图 [{currentUser=null, viewScope=map[[empty]], componentTemplatePath=/MyTMLT/templates/components/risk/practiceReview.ftl, flowExecutionKey =e7s1, flowExecutionUrl=/riskpracticereviewrequest-flow?execution=e7s1, pageDescription=请填写下面的表格提交您的实践审查请求。, flashScope=map[[empty]], flowRequestContext=[RequestControlContextImpl@1eb4074 externalContext = org. springframework.webflow.mvc.servlet.MvcExternalContext@1f446e1,currentEvent = [null],requestScope = map[[empty]],attributes = map[[empty]],messageContext = [DefaultMessageContext@19f94a4 sourceMessages = map[[null] - > list[[empty]], 'physicians[0].name' -> list[[Message@17402e3 source = 'physicians[0].name', severity = ERROR, text = 'evaluationException on doctors[0].name ']]]], flowExecution = [FlowExecutionImpl@25b8a3 flow = 'riskpracticereviewrequest-flow', flowSessions = list[[FlowSessionImpl@ec7f63 flow = 'riskpracticereviewrequest-flow',状态 = 'practiceReviewRequest',范围 = map['viewScope' -> map[[empty]],'componentTemplatePath' -> '/MyTMLT/templates/components/risk/practiceReview.ftl',' pageDescription' -> '请填写下面的表格以提交您的练习审查请求。', 'practiceReviewForm' -> org.tmlt.data.model.impl.PracticeReviewRequestImpl@174ec05]]]]], org.springframework.validation .BindingResult.practiceReviewForm=org.springframework.webflow.mvc.view.BindingModel: 1 个错误
字段 'physicians[0].name' 上的对象 'practiceReviewForm' 中的字段错误:拒绝值 [null];代码 [];论据 [];默认消息 [evaluationException on doctors[0].name], practiceReviewForm=org.tmlt.data.model.impl.PracticeReviewRequestImpl@174ec05}]
2018-04-12 11:00:15,944 DEBUG ion.repository.impl.DefaultFlowExecutionRepository:放置流执行'[FlowExecutionImpl@25b8a3 flow ='riskpracticereviewrequest-flow',flowSessions = list[[FlowSessionImpl@ec7f63 flow ='riskpracticereviewrequest-flow' , state = 'practiceReviewRequest', scope = map['viewScope' -> map[[empty]], 'componentTemplatePath' -> '/MyTMLT/templates/components/risk/practiceReview.ftl', 'pageDescription' -> '请填写下面的表格以提交您的练习审查请求。', 'practiceReviewForm' -> org.tmlt.data.model.impl.PracticeReviewRequestImpl@174ec05]]]]' 到存储库
如果您有任何问题,请告诉我。我整个星期都被困在这上面。感谢您的宝贵时间。
【问题讨论】:
-
我在发布我的 html 时遇到了问题,但这里是:跨度>