Note that there are some explanatory texts on larger screens.

plurals
  1. POget all authorities of a specific user
    primarykey
    data
    text
    <p>I've got a <code>User</code> entity and each user which exists should have 1 or more specific roles/authorities. For example <code>admin</code> <code>user</code>and so on. So I created an <code>authorities</code> table with 2 fields (<code>username</code> and <code>authority</code>) In my <code>application-context-securtiy.xml</code> I have</p> <pre><code>&lt;jdbc-user-service id="userService" data-source-ref="dataSource" users-by-username-query=" select nickname, password, true from users where nickname=?" authorities-by-username-query= "select username, authority AS authorities from authorities where username=?" /&gt; </code></pre> <p>which is working quite good.</p> <p>Right now I'm trying to create a jsp file which lists all of my users and their roles/authorities but I'M not able todo something like <code>user.getAuthorites()</code> and print them in the jsp.</p> <p>I already tried implemented a <code>UserDetailsService</code> but I don't know how to connect my User and the UserDetailsService.</p> <p>Hope you can give me some advice.</p> <p>Edit: part of the jsp how I would like to use it:</p> <pre><code>&lt;tbody&gt; &lt;c:forEach var="user" varStatus="stats" items="${users}"&gt; &lt;tr&gt; &lt;td&gt; &lt;c:out value="${user.nickname}" /&gt; &lt;c:forEach var="role" varStatus="status_" items="${user.getAuthorities()}"&gt; &lt;c:out value="${role}" /&gt; &lt;/c:forEach&gt; &lt;/td&gt; &lt;td&gt;test&lt;/td&gt; &lt;td&gt;options&lt;/td&gt; &lt;/tr&gt; &lt;/c:forEach&gt; &lt;/tbody&gt; </code></pre> <p>How I send data from controller to my view:</p> <pre><code>@RequestMapping(value = "/manageUsers", method = RequestMethod.GET) public String startManageUsers(ModelMap model, Principal principal) { List&lt;User&gt; list = userService.getUsers(); model.addAttribute("users", list); return "showUsers"; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload