I'm currently working on a web project written in java. Coming from Symfony2 background, I'm looking for a way to handle web form generation and validation similar to Symfony's Form component. What this component does is generate a form based on an Entity
and validate it upon submission. There is also a possibility to have nested/embedded sub-forms.
我目前正在开发一个用java编写的web项目。来自Symfony2背景,我正在寻找一种方法来处理类似于Symfony的Form组件的Web表单生成和验证。该组件的作用是生成基于实体的表单,并在提交时对其进行验证。还有可能有嵌套/嵌入子表单。
Is there a similar library/framework I could use in java to achieve the same results? Is there a way to do this with Spring, perhaps?
我可以在java中使用类似的库/框架来实现相同的结果吗?有没有办法用Spring做到这一点,也许?
2 个解决方案
#1
yes it is possible, see: http://www.thymeleaf.org/doc/tutorials/2.1/thymeleafspring.html#dynamic-fields
是的,有可能,请参阅:http://www.thymeleaf.org/doc/tutorials/2.1/thymeleafspring.html#dynamic-fields
http://www.bincsoft.com/blog/thymeleaf-and-lists-in-forms/
Thymeleaf and #fields.hasErrors
Thymeleaf和#fields.hasErrors
#2
At the time I posted this question there wasn't really a good answer to this question. It seems that now you can use Spring Validation Form which is quite similar to Symfony's Form Validation.
当我发布这个问题时,对这个问题没有一个好的答案。现在看来,您可以使用与Symfony的表单验证非常相似的Spring Validation Form。
#1
yes it is possible, see: http://www.thymeleaf.org/doc/tutorials/2.1/thymeleafspring.html#dynamic-fields
是的,有可能,请参阅:http://www.thymeleaf.org/doc/tutorials/2.1/thymeleafspring.html#dynamic-fields
http://www.bincsoft.com/blog/thymeleaf-and-lists-in-forms/
Thymeleaf and #fields.hasErrors
Thymeleaf和#fields.hasErrors
#2
At the time I posted this question there wasn't really a good answer to this question. It seems that now you can use Spring Validation Form which is quite similar to Symfony's Form Validation.
当我发布这个问题时,对这个问题没有一个好的答案。现在看来,您可以使用与Symfony的表单验证非常相似的Spring Validation Form。