亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? actionservlet.java

?? easyweb的使用
?? JAVA
字號:
package com.easyjf.web;

import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.context.Context;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.util.SimplePool;

import com.easyjf.web.config.WebConfig;

/**
 * 
 * <p>
 * Title:EasyJWeb核心Servlet
 * </p>
 * <p>
 * Description: EasyJWeb核心Servlet,所有的.ejf訪問都將由該Servlet處理
 * 用戶必須在web.xml文件指定擴展名為.ejf的訪問都指向該類或其子類。
 * </p>
 * <p>
 * Copyright: Copyright (c) 2006
 * </p>
 * <p>
 * Company: www.easyjf.com
 * </p>
 * 
 * @author 蔡世友
 * @version 1.0
 */

public class ActionServlet extends HttpServlet {
	static final long serialVersionUID = 8880L;

	private static final Logger logger = (Logger) Logger
			.getLogger(ActionServlet.class.getName());

	public static final String DEFAULT_OUTPUT_ENCODING = "UTF-8";

	public static final String SERVLET_CONTEXT_KEY = ServletContext.class
			.getName();

	private static SimplePool writerPool = new SimplePool(60);

	private String defaultContentType;

	private boolean warnOfOutputStreamDeprecation = true;

	public void init(ServletConfig config) throws ServletException {
		super.init(config);
		Globals.CONFIG_FILE_FULL_PATH = getServletConfig().getServletContext()
				.getRealPath(Globals.CONFIG_FILE);
		Globals.APP_BASE_DIR = getServletConfig().getServletContext()
				.getRealPath("/");
		// logger.info("init");
		WebConfig.getInstance().init();
		// logger.info("do init apps");
		List apps = WebConfig.getInstance().getInitApps();
		// logger.info("apps.size:"+apps.size());
		for (int i = 0; i < apps.size(); i++) {

			try {
				Map app = (Map) apps.get(i);
				Method init = (Method) app.get("init");
				if (init != null) {
					init.invoke(app.get("classname"), null);
					// logger.info("init app:"+init.getClass().getName()+"init
					// method"+init.getName());
				}
			} catch (Exception e) {

			}
		}
		initTemplate(config);
	}

	public void destroy() {
		// TODO Auto-generated method stub
		List apps = WebConfig.getInstance().getInitApps();
		for (int i = 0; i < apps.size(); i++) {
			try {
				Map app = (Map) apps.get(i);
				Method des = (Method) app.get("destroy");
				if (des != null) {
					des.invoke(app.get("classname"), null);
					System.out.println("destroy app:"
							+ des.getClass().getName() + "destroy method"
							+ des.getName());

				}
			} catch (Exception e) {

			}
		}
		super.destroy();
	}

	/**
	 * 初始化模板
	 * 
	 * @param config
	 * @throws ServletException
	 */
	protected void initTemplate(ServletConfig config) throws ServletException {
		Velocity.setApplicationAttribute(SERVLET_CONTEXT_KEY,
				getServletContext());
		Properties p = new Properties();
		if (WebConfig.getInstance().getTemplateBasePath() == null
				|| WebConfig.getInstance().getTemplateBasePath().equals(""))
			WebConfig.getInstance().setTemplateBasePath(
					Globals.DEFAULT_TEMPLATE_PATH);
		String realTemplatePath = WebConfig.getInstance().getTemplateBasePath();
		File file = new File(WebConfig.getInstance().getTemplateBasePath());
		if (!file.exists())
			realTemplatePath = config.getServletContext().getRealPath(
					WebConfig.getInstance().getTemplateBasePath());
		p.setProperty("file.resource.loader.path", realTemplatePath);
		// System.out.println(realTemplatePath);

		try {
			Velocity.init(p);
		} catch (Exception e) {
			logger.error("ActionServlet: PANIC! unable to init() - " + e);
			throw new ServletException(e);
		}
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doRequest(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doRequest(request, response);
	}

	/**
	 * 處理用戶請求
	 * 
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	 */
	protected void doRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// 初始化Request
		try {
			doInitRequest(request, response);
		} catch (Exception e) {
			info(request, response, e);
			return;
		}
		Context context = null;
		try {
			setContentType(request, response);
			RequestProcessor rp = new RequestProcessor(this);
			rp.process(request, response);
		} catch (Exception e) {
			logger.error("ActionServlet出現嚴重錯誤:" + e);
			error(request, response, e);
		} finally {
			requestCleanup(request, response, context);
		}
	}

	protected boolean doInitRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		Map map = new HashMap();
		map.put(ActionContext.HTTP_REQUEST, request);
		map.put(ActionContext.HTTP_RESPONSE, response);
		ActionContext.setContext(new ActionContext(map));
		if (WebConfig.getInstance().isDebug()) {// 調試模式每次都要初始化配置文件
			WebConfig.getInstance().init();// 初始化配置文件
			initTemplate(getServletConfig()); // 初始化模版
		}
		// 執行攔截操作
		Iterator interceptors = FrameworkEngine.getRequestInterceptors();
		if (interceptors != null) {
			while (interceptors.hasNext()) {
				IRequestInterceptor interceptor = (IRequestInterceptor) interceptors
						.next();
				Object result = interceptor.doIntercept();
				if (result instanceof Page) {
					response.sendRedirect(((Page) result).getUrl());
					return false;
				}
				// else if(result instanceof )
			}
		}

		return true;
	}

	// 清除request中的相關資料,此處為空
	protected void requestCleanup(HttpServletRequest request,
			HttpServletResponse response, Context context) {

	}

	protected void setContentType(HttpServletRequest request,
			HttpServletResponse response) {

		response.setContentType(defaultContentType);
	}

	/**
	 * 輸出系統框架錯誤信息提示
	 * 
	 * @param request
	 * @param response
	 * @param e
	 * @throws ServletException
	 */
	protected void error(HttpServletRequest request,
			HttpServletResponse response, Exception e) throws ServletException {
		try {
			StringBuffer html = new StringBuffer();
			String title = request.getCharacterEncoding() != null ? "EasyJWeb框架錯誤"
					: "EasyJWeb Framework error";
			html.append("<html>\n");
			html.append("<head><title>" + title + "</title></head>\n");
			html.append("<body>\n");
			html.append(title + ":\n<br>");
			Throwable cause = e;
			String why = cause.getMessage();
			html.append("<font color=red>");
			if (why != null && why.trim().length() > 0) {
				html.append(why);
				html
						.append("\n<br>詳細請查詢<a href='http://www.easyjf.com/' target='_blank'>http://www.easyjf.com</a>\n");
			}
			if (cause instanceof MethodInvocationException) {
				cause = ((MethodInvocationException) cause)
						.getWrappedThrowable();
			}
			html.append("</font>");

			StringWriter sw = new StringWriter();
			cause.printStackTrace(new PrintWriter(sw));
			html.append("<pre>\n");
			html.append(sw.toString());
			html.append("</pre>\n");
			html.append("</body>\n");
			html.append("</html>");
			if (request.getCharacterEncoding() != null)
				response.setContentType("text/html; charset="
						+ request.getCharacterEncoding());
			getResponseWriter(response).write(html.toString());
		} catch (Exception e2) {
			logger
					.error("ActionServlet: Exception while printing error screen: "
							+ e2);
			throw new ServletException(e);
		}
	}

	protected void info(HttpServletRequest request,
			HttpServletResponse response, Exception e) throws ServletException {
		try {
			StringBuffer html = new StringBuffer();
			String title = request.getCharacterEncoding() != null ? "EasyJWeb框架友情提示!:-)"
					: "EasyJWeb Framework Friendly Info!";
			html.append("<html>\n");
			html.append("<head><title>" + title + "</title></head>\n");
			html.append("<body>\n");
			html.append(title + ":\n<br>");
			Throwable cause = e;
			String why = cause.getMessage();
			html.append("<font color=red>");
			if (why != null && why.trim().length() > 0) {
				html.append(why);
				html
						.append("\n<br>詳細請查詢<a href='http://www.easyjf.com/' target='_blank'>http://www.easyjf.com</a>\n");
			}
			if (cause instanceof MethodInvocationException) {
				cause = ((MethodInvocationException) cause)
						.getWrappedThrowable();
			}
			html.append("</font>");
			html.append("</body>\n");
			html.append("</html>");
			if (request.getCharacterEncoding() != null)
				response.setContentType("text/html; charset="
						+ request.getCharacterEncoding());
			getResponseWriter(response).write(html.toString());
		} catch (Exception e2) {
			logger
					.error("ActionServlet: Exception while printing error screen: "
							+ e2);
			throw new ServletException(e);
		}
	}

	protected Writer getResponseWriter(HttpServletResponse response)
			throws UnsupportedEncodingException, IOException {
		Writer writer = null;
		try {
			writer = response.getWriter();
		} catch (IllegalStateException e) {
			if (this.warnOfOutputStreamDeprecation) {
				this.warnOfOutputStreamDeprecation = false;

			}
			String encoding = response.getCharacterEncoding();
			if (encoding == null) {
				encoding = DEFAULT_OUTPUT_ENCODING;
			}
			writer = new OutputStreamWriter(response.getOutputStream(),
					encoding);
		}
		return writer;
	}

	public static SimplePool getWriterPool() {
		return writerPool;
	}

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产91对白在线观看九色| 久久久青草青青国产亚洲免观| 亚洲欧美另类小说| 色www精品视频在线观看| 亚洲青青青在线视频| 91免费看`日韩一区二区| 亚洲视频电影在线| 欧美午夜宅男影院| 青椒成人免费视频| 久久久久九九视频| 色综合久久久网| 日本亚洲欧美天堂免费| 久久夜色精品国产噜噜av| 国产精品影视网| 亚洲人成小说网站色在线| 欧美日韩一区三区四区| 精品一区二区久久| 亚洲美女在线国产| 欧美一区二区三区四区高清| 国产老妇另类xxxxx| 亚洲乱码中文字幕| 欧美一区二区三区人| 国产成人午夜精品影院观看视频| 亚洲三级电影全部在线观看高清| 欧美影院一区二区| 国产一区二区三区在线观看精品 | 国产精品乱子久久久久| 色综合色综合色综合色综合色综合 | 欧美成人女星排行榜| 成人手机在线视频| 首页欧美精品中文字幕| 国产偷国产偷精品高清尤物| 欧美视频在线一区| 成人美女在线视频| 日本不卡高清视频| 一区二区三区精密机械公司| 日韩精品在线一区二区| 色噜噜狠狠成人网p站| 国内精品自线一区二区三区视频| 一区二区视频在线| 国产日产欧美精品一区二区三区| 91精品在线麻豆| 91精品1区2区| 丁香亚洲综合激情啪啪综合| 日本成人在线一区| 亚洲一区自拍偷拍| 亚洲欧洲一区二区在线播放| 精品国产凹凸成av人网站| 91久久精品国产91性色tv| 福利一区福利二区| 久久爱www久久做| 亚洲国产欧美日韩另类综合| 国产精品成人在线观看| 精品91自产拍在线观看一区| 欧美日韩国产免费一区二区| 99国产精品久久久久久久久久| 国精产品一区一区三区mba桃花 | 欧美综合久久久| 99免费精品在线| 国产91在线观看| 国产剧情一区二区| 久久国产欧美日韩精品| 日欧美一区二区| 午夜电影网一区| 午夜精品久久久久久久久久久 | 91精品国产aⅴ一区二区| 在线观看一区不卡| 色老汉一区二区三区| 91免费在线播放| 一本久久精品一区二区| 色综合一个色综合亚洲| 91丨九色porny丨蝌蚪| 91在线国产福利| 色综合久久久久久久| 色视频欧美一区二区三区| 99久久99久久久精品齐齐| av在线一区二区| 91麻豆swag| 91高清视频在线| 欧美亚洲禁片免费| 欧美精品丝袜中出| 欧美一区二区三区四区五区| 日韩一区二区在线看| 精品福利一区二区三区免费视频| 欧美精品一区二区精品网| 久久久www成人免费毛片麻豆| 久久久av毛片精品| 中文字幕中文乱码欧美一区二区| 国产精品网曝门| 一区二区三区四区高清精品免费观看| 亚洲激情自拍偷拍| 亚洲成a人v欧美综合天堂下载| 日本伊人色综合网| 国产一区999| av在线不卡电影| 欧美亚洲国产一区在线观看网站| 欧美精品少妇一区二区三区 | 欧美极品少妇xxxxⅹ高跟鞋| 国产精品乱码人人做人人爱 | 午夜欧美2019年伦理| 男女男精品视频网| 国产aⅴ综合色| 欧美主播一区二区三区| 日韩精品影音先锋| 亚洲人成精品久久久久| 蜜桃av一区二区三区电影| 国产精品综合久久| 在线亚洲+欧美+日本专区| 日韩精品一区二区在线| 国产精品不卡一区| 日韩精品欧美精品| 国产91丝袜在线播放| 欧美情侣在线播放| 国产欧美一区二区精品久导航 | 日韩免费看的电影| 国产精品视频免费| 午夜久久久影院| 国产美女一区二区| 欧美日韩精品高清| 国产精品久久久久久久久晋中 | 午夜伊人狠狠久久| 成人一区二区三区| 欧美顶级少妇做爰| 综合色中文字幕| 日本视频在线一区| 91麻豆免费在线观看| ww久久中文字幕| 亚洲va欧美va天堂v国产综合| 国产成人午夜视频| 日韩一区二区在线免费观看| 亚洲精品日韩综合观看成人91| 久久99精品久久只有精品| 91福利社在线观看| 欧美激情一区三区| 久久不见久久见中文字幕免费| 色婷婷综合久色| 久久精品亚洲精品国产欧美 | 成人一级片在线观看| 欧美成人欧美edvon| 亚洲va在线va天堂| 日本精品视频一区二区三区| 日本一区二区视频在线观看| 美女任你摸久久| 久久色在线观看| 亚洲高清视频中文字幕| 白白色 亚洲乱淫| 久久精品男人天堂av| 日韩电影在线一区二区三区| 色播五月激情综合网| 亚洲欧美综合另类在线卡通| 粉嫩av一区二区三区在线播放| 欧美成人伊人久久综合网| 日本视频一区二区三区| 欧美高清你懂得| 亚洲国产精品欧美一二99| 色av一区二区| 一个色在线综合| 91久久精品网| 亚洲国产日韩在线一区模特 | 国产不卡一区视频| 久久一夜天堂av一区二区三区| 蜜臀精品久久久久久蜜臀| 91精品国产一区二区三区| 亚洲h在线观看| 欧美日韩一区中文字幕| 天堂成人免费av电影一区| 在线不卡中文字幕| 婷婷久久综合九色国产成人| 欧美日本免费一区二区三区| 五月激情综合色| 欧美精品日韩综合在线| 日本系列欧美系列| 精品区一区二区| 国产成人亚洲综合a∨婷婷| 亚洲国产精品激情在线观看| 成人激情校园春色| 亚洲黄色片在线观看| 欧美日韩亚州综合| 蜜桃久久久久久| 国产三级三级三级精品8ⅰ区| 成人精品国产一区二区4080| 亚洲女性喷水在线观看一区| 欧美性色黄大片| 麻豆国产91在线播放| 国产日韩欧美精品综合| av福利精品导航| 亚洲成a天堂v人片| 精品噜噜噜噜久久久久久久久试看 | 国产成人av一区二区三区在线 | 99久久777色| 亚洲国产aⅴ天堂久久| 日韩一本二本av| 成人综合婷婷国产精品久久蜜臀 | 国产精品人成在线观看免费| 97精品久久久久中文字幕| 午夜精品影院在线观看| 精品成人一区二区| 色天使久久综合网天天| 久久99国产精品久久99| 最好看的中文字幕久久|