如何在春季 roo 中使用 activerecord.aj 文件的方法



我试图在Spring Roo Project中的表格中获得原始总数的价值。这可以通过Spring Roo的AxpectJ文件的内置方法来完成。

UserAccount_Roo_Jpa_ActiveRecord.aj文件中定义为以下的方法:

  public static long UserAccount.countUserAccounts() {
         return entityManager().createQuery("SELECT COUNT(o) FROM UserAccount o", Long.class).getSingleResult();
  }

我想将此长的值打印到我的JSPX页面。如何调用此方法以及从哪里打电话?需要帮忙。thnx。

自定义处理相关请求的控制器方法:

1:推入控制器方法,例如。show方法

2:修改该方法运行查询并放置可视图层的结果:

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String show(@PathVariable("id") Long id, Model uiModel) {
    ...
    Long count = UserAccount.countUserAccounts();
    uiModel.addAttribute("countUserAccounts", count);
    ...
}

3:根据需要修改JSPX。

最新更新