⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eosrequest.java

📁 EOS的一个很好的例子.包括页面构件、展现构件
💻 JAVA
字号:
package com.primeton.eos.fbframe.fbrole.security.impl;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import com.primeton.eos.fbframe.config.*;
/**
 * @author ZhangXueyong
 */
public class EOSRequest {
	
	public static final int LOGIN_FOR_EOS    = -1;
	//不属于EOS管辖的资源
	public static final int EOS_NOT_INVOLVED = 0;
	//直接调用"展现逻辑"的情况
	public static final int EOS_PRLOGIC      = 1;
	//通过forward调用jsp的情况
	public static final int EOS_FORWARD_JSP  = 13;
	//通过forward调用的jsp调用业务逻辑的情况
	public static final int EOS_FORWARD_BIZ  = 12;
	//直接调用“业务逻辑”的情况
	public static final int EOS_BIZLOGIC     = 2;
	//直接调用jsp 的情况
	public static final int EOS_JSPLOGIC     = 3;
	
	private String EOSRequestURL;
	private String EOSResourceName;
	private int EOSRequestType;
	private HttpServletRequest rq;
	
	private EOSRequest(String EOSRequestURL,
						String EOSResourceName,
						int EOSRequestType,
						HttpServletRequest rq)
	{
		this.EOSRequestType = EOSRequestType;
		this.EOSRequestURL = EOSRequestURL;
		this.EOSResourceName = EOSResourceName;
		this.rq = rq;
	}
	
	/*
	 * 根据HttpServletRequest的内容生成EOSRequest对象 。
	 * 
	 */
	public static EOSRequest buildEOSRequest(HttpServletRequest rq){
		
		String url = "";
		String name = "";
		
		String actionName = rq.getServletPath();
		int eosType = EOSRequest.EOS_NOT_INVOLVED;
		//展现逻辑的后缀
		String pr_postfix = FbFrameConfig.getInstance().getPrActionPostfix();
		if( actionName.endsWith(pr_postfix) ){
//------------------------------------------------------>>>>>			
			//取得展现逻辑的全名称
			String TempActionName = getEOSRequest_PrLogicUrl(actionName);	
			//通过forward.do可调用的jsp和业务逻辑
			if( TempActionName.endsWith("forward" + pr_postfix) ){
				TempActionName = rq.getParameter("nextPage");
				//调用“业务逻辑”的情况 
				if(TempActionName != null 
						&& (TempActionName.endsWith("fbtools/page/hiddensubmit.jsp") || TempActionName.endsWith("/fbtools/page/hiddensubmit.jsp")) 
						&& rq.getParameter("bizAction") != null)
				{
					eosType = EOS_FORWARD_BIZ;
					url = rq.getParameter("bizAction");;
					name = url;
				}else if( TempActionName != null ){
				//调用“JSP”的情况
					eosType = EOS_FORWARD_JSP;
					url = TempActionName;
					name = TempActionName;
				}else{
			    //没有调用EOS可控的资源
					eosType = EOS_NOT_INVOLVED;
				}
			}else{
			//调用 “展现逻辑”的情况
				eosType = EOS_PRLOGIC;
				url = TempActionName;
				name = getEOSRequest_PrLogicName(actionName);
			}
//<<<<<------------------------------------------------------			
		} else if(actionName.endsWith(".jsp")){
			url = actionName;
			name = actionName;
			eosType = EOS_JSPLOGIC;
			if (actionName.endsWith("fbtools/page/hiddensubmit.jsp")) {
				try {
					rq.setCharacterEncoding("UTF-8");
				} catch (UnsupportedEncodingException e) {
					// TODO 自动生成 catch 块
					e.printStackTrace();
				}
				url = rq.getParameter("bizAction");
				if (url != null) {
					eosType = EOS_FORWARD_BIZ;
					name = url;
				} else {
					eosType = EOS_NOT_INVOLVED;
					url = actionName;
				}
			}
		} else if(actionName.endsWith(".call") && rq.getParameter("bizAction") != null){
			eosType = EOS_BIZLOGIC;
			url = rq.getParameter("bizAction");
			name = url;
		} else {
			eosType = EOS_NOT_INVOLVED;
		}		
		
		return new EOSRequest(url,name,eosType,rq);
	}
	
	/*
	 * 从请求的URL中取得展现逻辑的全名包含后缀 。
	 */
	private static String getEOSRequest_PrLogicUrl(String rawAction){
		int p = rawAction.lastIndexOf("/");
		rawAction = rawAction.substring(p+1);
		return rawAction;
	}
	
	/*
	 * 从请求的URL中取得展现逻辑的全名不包含后缀 。
	 */
	private static String getEOSRequest_PrLogicName(String rawAction){
		String actionName = rawAction;
        int slash = actionName.lastIndexOf("/");
        String pr_postfix = FbFrameConfig.getInstance().getPrActionPostfix();
        int period = actionName.lastIndexOf(pr_postfix);
        if(period >= 0 && period > slash)
        	actionName = actionName.substring(slash + 1, period);
		return actionName;
	}
	
	/*
	 * 从请求的URL中取得JSP的全路径名 。
	 */
	private static String getJSPLogicAllName(HttpServletRequest rq){
		
		String context = rq.getContextPath();
		String rquestUrl = rq.getServletPath();
		
		if( context != null && context.length() != 0 ){
			int o = rquestUrl.indexOf(context);
		}
		return rquestUrl;
	}
	
	public String getEOSRequestURL(){
		return this.EOSRequestURL;
	}
	
	public String getEOSResourceName(){
		return this.EOSResourceName;
	}
	
	public int getEOSRequestType(){
		return this.EOSRequestType;
	}
	public void setEOSRequestType(int type){
		this.EOSRequestType = type;
	}
	public HttpServletRequest getHttpServletRequest(){
		return this.rq;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -