2015-12-30 26 views
0

我不明白我如何使用一个查找器,它只需要一个参数来显示返回的数据。 例如,我在原理实体中有一个发现者findPrincipalsByUsernameLike(String username),如何使用list.jspx中的此发现者向用户显示他/她的数据?在视图中使用查找器

Principle.java

@RooJavaBean 
@RooToString 
@RooJpaActiveRecord(table = "security_principals", finders = { "findPrincipalsByUsernameLike" }) 
public class Principal { 

    @NotNull 
    @Size(min = 5, max = 50) 
    private String username; 

    @NotNull 
    @Size(min = 5, max = 50) 
    private String password; 


    private Boolean enabled; 
} 

用户/ list.jspx

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<div xmlns:jsp="http://java.sun.com/JSP/Page" 
    xmlns:page="urn:jsptagdir:/WEB-INF/tags/form" 
    xmlns:table="urn:jsptagdir:/WEB-INF/tags/form/fields" version="2.0"> 
    <jsp:directive.page contentType="text/html;charset=UTF-8" /> 
    <jsp:output omit-xml-declaration="yes" /> 

    <page:find finderName="findPrincipalsByUsernameLike" 
     id="ff_edu_gju_syria_model_security_principal" 
     path="/principals/find"> 
     <input data-dojo-props="trim:true" data-dojo-type="dijit/form/TextBox" 
      id="toolbarFilter" name="filter" type="text" value="${filter}" /> 
    </page:find> 
    <page:list id="pl_edu_gju_syria_model_security_Principal" 
     items="${principals}" z="+E0uiC5dOFGeuICZbYdoS6Nz80o="> 
     <table:table data="${principals}" 
      id="l_edu_gju_syria_model_security_Principal" path="/security/users" 
      z="9ue3QOERNh44QuGQIg9JQzmFKnI="> 
      <table:column id="c_edu_gju_syria_model_security_Principal_username" 
       property="username" z="REKFqtjHv0gJUiSxe+y1TKytm1w=" /> 
      <table:column id="c_edu_gju_syria_model_security_Principal_password" 
       property="password" z="4khHEC8FhwrPHVFPG7c4s5cP8L4=" /> 
      <table:column id="c_edu_gju_syria_model_security_Principal_enabled" 
       property="enabled" z="boq7MuGPymSQN1CCWrQ8INhy1DM=" /> 
     </table:table> 
    </page:list> 
</div> 

如何传递当前用户名不显示用户的文本区域?

回答

0

您不必以请求参数发送用户。

在处理请求的Controller方法中,只需从请求中获取用户主体。

Spring Security 3.2引入了很大的改进,以方便用户细节管理,看看How to get active user's UserDetails