Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嗨,如果我在控制器中有以下代码,那么在提供网页后,人员对象会被销毁吗?
Person p = new Person(); for (int u =0 ...) { p = new Person(); p.save(); }
是的,服务请求后对象实例全部销毁。在您的示例中,请求中仅存在数据库中的数据。
在官方文档中阅读有关 Grails 控制器的更多信息。有关可以跨请求存储变量的不同范围,请参阅控制器和范围部分。