与登录用户相关的内置参数列表:
Parameter Name | Type | Notes | Standard? |
LoggedInUser | User | Not usable in query input control, but is used as parameter to report | Yes |
LoggedInUsername | String | Of logged in user | Yes |
LoggedInUserFullName | String | Of logged in user | No |
LoggedInUserEmailAddress | String | Of logged in user | No |
LoggedInUserEnabled | Boolean | Is logged in user enabled? | No |
LoggedInUserExternallyDefined | Boolean | Is logged in user externally defined? ie. authenticated externally | No |
LoggedInUserTenantId | String | Of logged in user. Only relevant in Pro/Enterprise. | No |
LoggedInUserRoles | Collection<string> | Current set of roles of logged in user. Useful for $X parameter | No |
LoggedInUserAttributes | Map<string, string> | Not usable in query input control, but is used as parameter to report. Empty map if no attributes | No |
LoggedInUserAttributeNames | Collection<string> | User profile attribute names. Useful for $X parameters. Empty collection if no attributes | No |
LoggedInUserAttributeValues | Collection | - | No |
LoggedInUserAttribute_<attribute name> | String | Attribute value for matched attribute name (like "att1") on the user. Empty string if no match. Only provided if defined in a query or as a report parameter. | No |
创建参数LoggedInUser,引用类:com.jaspersoft.jasperserver.api.metadata.user.domain.User
其他登录用户相关内置变量设置成相应的STRING、MAP、COLLECTION等即可。
设计报表:
只能在服务器上查看效果:
代码段:
<parametername="LoggedInUser"class="com.jaspersoft.jasperserver.api.metadata.user.domain.User" isForPrompting="false"/>
<parametername="LoggedInUsername" class="java.lang.String"isForPrompting="false"/>
<parametername="LoggedInUserFullName" class="java.lang.String"isForPrompting="false"/>
<parametername="LoggedInUserEmailAddress" class="java.lang.String"isForPrompting="false"/>
<parametername="LoggedInUserEnabled" class="java.lang.Boolean"isForPrompting="false"/>
<parametername="LoggedInUserExternallyDefined"class="java.lang.Boolean" isForPrompting="false"/>
<parametername="LoggedInUserTenantId" class="java.lang.String"isForPrompting="false"/>
<parametername="LoggedInUserRoles" class="java.util.Collection"isForPrompting="false"/>
<parametername="LoggedInUserAttributes" class="java.util.Map"isForPrompting="false"/>
<parametername="LoggedInUserAttributeNames"class="java.util.Collection" isForPrompting="false"/>
<parametername="LoggedInUserAttributeValues"class="java.util.Collection" isForPrompting="false"/>
Examples
Print When Expression example:
($P{LoggedInUserRoles}.toString().contains("ROLE_ADMINISTRATOR"))? new Boolean(true) : new Boolean(false)
Page footer example:
"Last printed by " +$P{LoggedInUserFullName} + " on " + new java.util.Date() +"\n LoggedInUserRoles include: " + $P{LoggedInUserRoles}.toString()
使用URL传递用户名和密码
http://104.197.68.11/jasperserver/flow.html?_flowId=viewReportFlow&_flowId=viewReportFlow&ParentFolderUri=%2Freports&reportUnit=%2Freports%2FAPAuditWithLicense&standAlone=true&j_acegi_security_check&j_username=jasperadmin&j_password=.......&decorate=no&output=pdf?LicenseId=1
PDF下载:http://download.csdn.net/download/qq_16215957/10010562
作者:狮子王
经历:从事大型企业信息化工作22年,擅长IT战略管理,覆盖运维、开发、大数据等领域。
QQ:179170396