?? authoritytag.java
字號:
package cn.hxex.exam.taglib;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import cn.hxex.exam.struts.StrutsConstants;
/**
* 用戶權(quán)限校驗的標簽
*
* @jsp.tag name="authority" body-content="empty"
*
* @author galaxy
*
*/
public class AuthorityTag extends TagSupport
{
protected final Log log = LogFactory.getLog(getClass());
public int doEndTag() throws JspException
{
// 得到用戶請求對象
HttpServletRequest request = (HttpServletRequest) pageContext
.getRequest();
Boolean checked = (Boolean) request
.getAttribute(StrutsConstants.REQUEST_CHECK_FLAG);
// 判斷是否已經(jīng)進行了權(quán)限校驗
if (checked != null && checked.booleanValue())
return EVAL_PAGE;
// 對于沒有通過權(quán)限校驗的訪問,返回到登錄頁面
HttpServletResponse response = (HttpServletResponse) pageContext
.getResponse();
try
{
response.sendRedirect(request.getContextPath() + "/logon.jsp");
}
catch (IOException ex)
{
throw new JspException(ex);
}
return SKIP_PAGE;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -