2011-05-13 52 views

回答

0

您可以列出所有可用的查找器,並使用the following documentation將您需要的查找器添加到您的應用程序中。您可以在corresponding question閱讀更多內容。

然後你就可以在對應的Spring MVC控制器添加Principal參數如下方式修改相應的方法:

@RequestMapping(method = RequestMethod.GET) 
public ModelAndView showResults(final HttpServletRequest request, Principal principal) { 
    final String currentUser = principal.getName(); 
    ... 
} 

記住你should't修改權ITD,但你應該把它複製到相應的*的.java首先控制器。在這種方法中,您應該修改使用查找器時使用的列表。

最後,您可以通過使用RooWebScaffold註釋的exposeFinders=false來排除腳手架上的動態查找器。

+0

確切地說以及如何獲取已驗證的用戶名,以便將其添加爲我的查找器的參數? – gpasse 2011-05-13 15:23:38

+0

我已經添加了更多可用的細節。 – Constantiner 2011-05-13 17:10:39

+0

謝謝。 爲什麼使用principal.getName()而不是SecurityContextHolder.getContext()。getAuthentication()。getName()? – gpasse 2011-05-14 16:48:58