小宗的啟示:不同型別的liferay使用者登入到不同頁面(登入跳轉個性化)——liferay5.0.1使用者登入後的跳轉(二)
在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>