在liferay5.0.1用戶登錄後的跳轉(一) 中,提到新建用戶在去掉首次登錄的條例說明,可以自動跳轉到portal.properties設置的固定頁面上。
問題又來了,在實際應用中,不同用戶需要登錄到不同頁面進行。而liferay設置的登錄跳轉是侷限的,使得不同用戶跳轉到一個同頁面上。
查找了很多資料,想了又想,也沒有找到解決辦法。
有一天小宗跟我說“用liferay權限解決,是不是可以?”
“對啊,還有權限可以利用上。”
起初的思路是:把不同用戶的首頁面寫在同一個.jsp文件上,把不同用戶的代碼用不用的權限括起來,相當於並列的if語句,形象描述如下:
if(權限1)
{
html.....頁面一
}
if(權限2)
{
html.....頁面一
}
if(權限3)
{
html.....頁面一
}
if(權限n)
{
html.....頁面一
}
start.jsp代碼:
<c:choose>
<c:when test='<%= permissionChecker.hasPermission(groupId, "com.sample.permissions.model.rollText", primKey, "INSERT_SERVICE") %>'>
<%@ include file="zhuce.jsp" %>
</c:when>
</c:choose>
<c:choose>
<c:when test='<%= permissionChecker.hasPermission(groupId, "com.sample.permissions.model.rollText", primKey, "UPDATE_SERVICE") %>'>
<%@ include file="caiwu.jsp" %>
</c:when>
</c:choose>
<c:choose>
<c:when test='<%= permissionChecker.hasPermission(groupId, "com.sample.permissions.model.rollText", primKey, "DELETE_SERVICE") %>'>
<%@ include file="jianhu.jsp" %>
</c:when>
</c:choose>
caiwu.jsp代碼:
<head>
<meta http-equiv="refresh" content="0;url='/group/25401/1'">
</head>
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<font size="5" color="blue">財務管理登錄中......</font>