Spring Web Flow 表单绑定
我有一个 java web 应用程序在 spring web flow 框架中运行,并且 hibernate 作为 ORM。我想问一下绑定表单值的最佳实践是什么。我是否创建一个代表每个表单的 pojo 或 bean,以便我有一个可以将表单绑定到的对象?我可以尝试将值作为 url 中的参数获取,但我认为这不是一个好方法。
我试图做的是将表单输入的值传递给 flow xml,并使用那里的值作为调用函数的参数。
<view-state id="editForm" model="registerBean" view="../xhtml/framework/edit">
<transition on="editButton" to="dummy" >
<set name="flowScope.newPassword" value="requestParameters.newPassword"/>
<set name="flowScope.confirmPassword" value="requestParameters.confirmPassword"/>
</transition>
<transition on="delete" to="deleteEmployee" />
<transition on="back" to="loginSuccessful" />
</view-state>
我在 xhtml 文件中打印了 ${newPassword} 但没有得到任何输出。所以我正在考虑有一个代表表单的对象并绑定值并在我的流程 xml 中访问它们
I have a java web app running in spring web flow framework and hibernate as ORM. I wanna ask what the best practice is with regards to binding the form values. Do I create a pojo or bean representing each form so that I have an object where I can bind the form to? I can try getting the values as parameters in the url but I don't think this is a good approach.
What I was trying to do is pass the values inputted from the forms to the flow xml and use the values there as parameters in calling functions.
<view-state id="editForm" model="registerBean" view="../xhtml/framework/edit">
<transition on="editButton" to="dummy" >
<set name="flowScope.newPassword" value="requestParameters.newPassword"/>
<set name="flowScope.confirmPassword" value="requestParameters.confirmPassword"/>
</transition>
<transition on="delete" to="deleteEmployee" />
<transition on="back" to="loginSuccessful" />
</view-state>
I printed ${newPassword} in an xhtml file but get no output. So I was thinking of having an object representing the form and bind the values and access them in my flow xml
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
直接将
与您的域(Hibernate)对象一起使用,如果填充数据,则无需额外的对象。如果每个屏幕有一个域对象,则可以使用 spring 的SimpleFormController
。Use
<form:bind>
directly with your domain (Hibernate) objects, no need of extra objects just for the sake if populating with data. If you have one domain object per screen, you can use spring'sSimpleFormController
.