如何使用 Grails 从一个视图保存多个对象
这个问题是这篇文章的后续问题 Grails 一对多关系视图
示例表明在运行时不起作用并抛出以下异常
null id in blog.omarello.Phone entry (don't flush the Session after an exception occurs). Stacktrace follows:
Message: null id in blog.omarello.Phone entry (don't flush the Session after an exception occurs)
Line | Method
->> 43 | doCall in blog.omarello.ContactController$_closure4$$ENLORkU6
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run . . in ''
^ 662 | run in java.lang.Thread
我认为任何人都可以帮助我理解如何创建一个 GSP,它可以让我保存同一域类的多个实例,而不是使示例工作。例如,一个 GSP 可以让我一次插入多个 Book 实例吗?
This question is in follow up to this post Grails one to many relationship view
The example suggested there is not working and throwing following exception at run time
null id in blog.omarello.Phone entry (don't flush the Session after an exception occurs). Stacktrace follows:
Message: null id in blog.omarello.Phone entry (don't flush the Session after an exception occurs)
Line | Method
->> 43 | doCall in blog.omarello.ContactController$_closure4$ENLORkU6
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run . . in ''
^ 662 | run in java.lang.Thread
I think rather then making the example work can any one help me understand how can I create a GSP which can let me save multiple instances of same domain class. For example, a GSP which can let me insert multiple Book instances at once?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
再次检查我在 github 上链接的项目。它演示了执行此操作的一些更好的实践。特别是,请查看 问题/ index,因为这就是视图的样子。实际的保存部分是在 QuestionService,由 QuestionController。这个项目完全完成了您想要做的事情。回顾一下。
Once again, examine the project I linked on github. It is a demonstration of some of the one of the better practices for doing this. Particularly, look at the question/index, as this is what the view can look like. The actual saving piece is done in the QuestionService, used by the QuestionController. This project does exactly what you're trying to do. Review it.
按如下所示更改电话示例中的 Contact 类,它应该可以正常工作。
Change the Contact class in the phone example as follows and it should work fine.