当对象具有多对多关系时,如何将对象从控制器发送到视图?
我有一个学校实体,它与年级有多对多的关系。 我可以成功加载我的 school 对象并将其发送到我的视图(这是一个 .ftl 页面,而不是 jspx),问题是;当我以 JSON 形式请求 url(仅接收序列化数据)(在执行 jquery get 后用于填充字段)时,我得到 --failed to lazily初始化角色集合:-- 我发现当我请求一个 JSON 格式的页面,并且该对象没有多对多关系,它会给我序列化字符串,但是当该对象具有多对多关系时,我会收到该错误。 有谁遇到过这个错误,或者知道我需要做什么?
I have a school entity and it has a many to many relationship with grade-levels.
I can successfully load my school object and send it to my view (which is a .ftl page, not jspx) the problem is; when I request the url as a JSON (to only receive the serialized data)(which I use to populate fields after doing a jquery get) I get a --failed to lazily initialize a collection of role:-- I have found that when I request a page as JSON and the object does not have a many to many relationship it will give me the serialized string just fine, however when the object has a many to many relationship I get that error.
Has anyone come across this error, or know what I need to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了这个解决方案,但我不知道它是否是最好的...有什么意见...我将此代码添加到我的 web.xml 文件中,
这允许对象返回。
希望它可以帮助任何尝试做同样事情的人。有谁有更好的解决方案或者这是正确的吗?
谢谢大家
I found this solution but i dont know if it is the best... any opinions... i added this code to my web.xml file
this allowed the object to come back.
hope it helps anyone that was trying to do the same thing. does anyone have a better solution or is this correct?
thanks everyone