我不明白如何使用带参数的finder仅显示返回的数据。
例如,我在Principle实体中有一个查找器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 :(得分:0)
您不必将用户作为请求参数发送。
在处理请求的Controller方法中,只需从请求中获取用户主体。
Spring Security 3.2引入了很多改进,以便于用户详细信息管理,请查看How to get active user's UserDetails