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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? myfreemarkerresult.java

?? JEECSM是JavaEE版網(wǎng)站管理系統(tǒng)(Java Enterprise Edition Content Manage System)的簡稱。基于java技術(shù)開發(fā)
?? JAVA
字號:
package com.ponyjava.common.struts2;

import java.io.IOException;
import java.io.Writer;
import java.util.Locale;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsStatics;
import org.apache.struts2.views.freemarker.FreemarkerManager;
import org.apache.struts2.views.util.ResourceUtil;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.LocaleProvider;
import com.opensymphony.xwork2.Result;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;

import freemarker.template.Configuration;
import freemarker.template.ObjectWrapper;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;

public class MyFreemarkerResult implements Result, StrutsStatics {
	private static final long serialVersionUID = 2824963114666563643L;
	public static final String PARSE_LOCATION = "ftlPath";
	/** The default parameter */
	public static final String DEFAULT_PARAM = "location";
	protected ActionInvocation invocation;
	protected Configuration configuration;
	protected ObjectWrapper wrapper;
	protected FreemarkerManager freemarkerManager;
	private Writer writer;

	private String pContentType = "text/html";

	protected String location;

	public MyFreemarkerResult() {
		this(null);
	}

	public MyFreemarkerResult(String location) {
		this.location = location;
	}

	@Inject
	public void setFreemarkerManager(FreemarkerManager mgr) {
		this.freemarkerManager = mgr;
	}

	public void setContentType(String aContentType) {
		pContentType = aContentType;
	}

	/**
	 * allow parameterization of the contentType the default being text/html
	 */
	public String getContentType() {
		return pContentType;
	}

	public void execute(ActionInvocation invocation) throws Exception {
		this.invocation = invocation;
		this.configuration = getConfiguration();
		this.wrapper = getObjectWrapper();

		parseLocation();
		Template template = configuration.getTemplate(location, deduceLocale());
		TemplateModel model = createModel();
		// Give subclasses a chance to hook into preprocessing
		if (preTemplateProcess(template, model)) {
			try {
				// Process the template
				template.process(model, getWriter());
			} finally {
				// Give subclasses a chance to hook into postprocessing
				postTemplateProcess(template, model);
			}
		}
	}

	private void parseLocation() {
		if (PARSE_LOCATION.equals(location)) {
			location = invocation.getStack().findString(PARSE_LOCATION);
		} else if (!location.startsWith("/")) {
			ActionContext ctx = invocation.getInvocationContext();
			HttpServletRequest req = (HttpServletRequest) ctx
					.get(ServletActionContext.HTTP_REQUEST);
			String base = ResourceUtil.getResourceBase(req);
			location = base + "/" + location;
		}
	}

	/**
	 * This method is called from {@link #doExecute(String, ActionInvocation)}
	 * to obtain the FreeMarker configuration object that this result will use
	 * for template loading. This is a hook that allows you to custom-configure
	 * the configuration object in a subclass, or to fetch it from an IoC
	 * container.
	 * <p/>
	 * <b> The default implementation obtains the configuration from the
	 * ConfigurationManager instance. </b>
	 */
	protected Configuration getConfiguration() throws TemplateException {
		return freemarkerManager.getConfiguration(ServletActionContext
				.getServletContext());
	}

	/**
	 * This method is called from {@link #doExecute(String, ActionInvocation)}
	 * to obtain the FreeMarker object wrapper object that this result will use
	 * for adapting objects into template models. This is a hook that allows you
	 * to custom-configure the wrapper object in a subclass.
	 * <p/>
	 * <b> The default implementation returns
	 * {@link Configuration#getObjectWrapper()} </b>
	 */
	protected ObjectWrapper getObjectWrapper() {
		return configuration.getObjectWrapper();
	}

	public void setWriter(Writer writer) {
		this.writer = writer;
	}

	/**
	 * The default writer writes directly to the response writer.
	 */
	protected Writer getWriter() throws IOException {
		if (writer != null) {
			return writer;
		}
		return ServletActionContext.getResponse().getWriter();
	}

	/**
	 * Build the instance of the ScopesHashModel, including JspTagLib support
	 * <p/>
	 * Objects added to the model are
	 * <p/>
	 * <ul>
	 * <li>Application - servlet context attributes hash model
	 * <li>JspTaglibs - jsp tag lib factory model
	 * <li>Request - request attributes hash model
	 * <li>Session - session attributes hash model
	 * <li>request - the HttpServletRequst object for direct access
	 * <li>response - the HttpServletResponse object for direct access
	 * <li>stack - the OgnLValueStack instance for direct access
	 * <li>ognl - the instance of the OgnlTool
	 * <li>action - the action itself
	 * <li>exception - optional : the JSP or Servlet exception as per the
	 * servlet spec (for JSP Exception pages)
	 * <li>struts - instance of the StrutsUtil class
	 * </ul>
	 */
	protected TemplateModel createModel() throws TemplateModelException {
		ServletContext servletContext = ServletActionContext
				.getServletContext();
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpServletResponse response = ServletActionContext.getResponse();
		ValueStack stack = ServletActionContext.getContext().getValueStack();

		Object action = null;
		if (invocation != null) {
			// Added for NullPointException
			action = invocation.getAction();
		}
		return freemarkerManager.buildTemplateModel(stack, action,
				servletContext, request, response, wrapper);
	}

	/**
	 * Returns the locale used for the
	 * {@link Configuration#getTemplate(String, Locale)} call. The base
	 * implementation simply returns the locale setting of the action (assuming
	 * the action implements {@link LocaleProvider}) or, if the action does not
	 * the configuration's locale is returned. Override this method to provide
	 * different behaviour,
	 */
	protected Locale deduceLocale() {
		if (invocation.getAction() instanceof LocaleProvider) {
			return ((LocaleProvider) invocation.getAction()).getLocale();
		} else {
			return configuration.getLocale();
		}
	}

	/**
	 * the default implementation of postTemplateProcess applies the contentType
	 * parameter
	 */
	protected void postTemplateProcess(Template template, TemplateModel data)
			throws IOException {
	}

	/**
	 * Called before the execution is passed to template.process(). This is a
	 * generic hook you might use in subclasses to perform a specific action
	 * before the template is processed. By default does nothing. A typical
	 * action to perform here is to inject application-specific objects into the
	 * model root
	 * 
	 * @return true to process the template, false to suppress template
	 *         processing.
	 */
	protected boolean preTemplateProcess(Template template, TemplateModel model)
			throws IOException {
		Object attrContentType = template.getCustomAttribute("content_type");

		if (attrContentType != null) {
			ServletActionContext.getResponse().setContentType(
					attrContentType.toString());
		} else {
			String contentType = getContentType();

			if (contentType == null) {
				contentType = "text/html";
			}

			String encoding = template.getEncoding();

			if (encoding != null) {
				contentType = contentType + "; charset=" + encoding;
			}

			ServletActionContext.getResponse().setContentType(contentType);
		}

		return true;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品一区二区三区蜜桃| 国内精品久久久久影院薰衣草| 777久久久精品| 麻豆精品一区二区综合av| 欧美最猛黑人xxxxx猛交| 亚洲精品久久7777| 国产精品国产三级国产有无不卡| 亚洲一区二区不卡免费| 欧美日韩一区二区三区不卡| 午夜久久福利影院| 在线电影国产精品| 乱一区二区av| 久久久久久久久岛国免费| 国产成人欧美日韩在线电影| 国产精品国产精品国产专区不蜜 | 久久精品人人做| 国产99精品国产| 亚洲免费资源在线播放| 欧美视频一区二区三区| 视频一区二区三区在线| 久久亚洲欧美国产精品乐播 | 免费一级欧美片在线观看| 精品国产乱码久久久久久影片| 丁香婷婷综合激情五月色| 亚洲精品成人a在线观看| 在线不卡免费av| 成人一级视频在线观看| 亚洲精品国产品国语在线app| 欧美精品三级日韩久久| 粗大黑人巨茎大战欧美成人| 亚洲综合一区二区| 99国产精品久久久久| 国产成人精品一区二区三区四区| 欧美丰满少妇xxxxx高潮对白| 精品一区二区三区久久| 久久aⅴ国产欧美74aaa| 亚洲欧洲精品一区二区精品久久久 | 日韩精品视频网站| 欧美—级在线免费片| 欧美精品自拍偷拍动漫精品| 成人免费看黄yyy456| 亚洲成人av福利| 国产精品久久久久影院老司| 欧美日韩国产中文| 99久久精品99国产精品| 久久成人久久鬼色| 一区二区高清视频在线观看| 久久久久久毛片| 欧美日本在线播放| 99国内精品久久| 国产成人自拍网| 美日韩一级片在线观看| 亚洲综合一区二区三区| 中文字幕不卡在线播放| 亚洲精品一区二区三区精华液 | 成人午夜短视频| 免费在线观看一区| 亚洲成年人影院| 亚洲免费观看在线视频| 老司机精品视频导航| 亚洲品质自拍视频| 国产精品久久久久一区 | 成+人+亚洲+综合天堂| 免费日本视频一区| 亚洲h动漫在线| 亚洲一区二区在线免费看| 亚洲私人影院在线观看| 国产日韩成人精品| 久久午夜羞羞影院免费观看| 欧美浪妇xxxx高跟鞋交| 欧美丝袜丝nylons| 色婷婷久久久久swag精品 | 91视频在线看| 成人精品一区二区三区中文字幕 | 欧美大片在线观看一区二区| 欧美精品日韩一区| 欧美久久一二区| 欧美精品v国产精品v日韩精品| 色狠狠av一区二区三区| 成人午夜看片网址| 成人国产精品免费网站| 成人av在线影院| 成人ar影院免费观看视频| 成人性生交大合| 国产精品一区二区在线观看网站| 狠狠色狠狠色合久久伊人| 美国欧美日韩国产在线播放| 美女网站视频久久| 蜜桃av一区二区三区电影| 日本不卡视频在线观看| 久久国产夜色精品鲁鲁99| 狠狠色丁香久久婷婷综合丁香| 蜜桃精品视频在线| 国产一区二区精品久久| 国产高清精品在线| 91在线视频官网| 在线观看区一区二| 这里是久久伊人| 亚洲精品一区二区三区在线观看| 久久久精品综合| 亚洲欧美一区二区视频| 亚洲伊人伊色伊影伊综合网| 午夜a成v人精品| 精品亚洲国产成人av制服丝袜| 国产美女精品在线| 成人app网站| 欧美日韩免费不卡视频一区二区三区| 91精品视频网| 国产亚洲一区二区三区在线观看| 中文字幕一区日韩精品欧美| 一个色在线综合| 久久精品久久综合| 高清国产午夜精品久久久久久| 91蜜桃网址入口| 4438x成人网最大色成网站| 久久久久久久久久久久电影 | 精品不卡在线视频| 国产精品久久久久永久免费观看 | 丝瓜av网站精品一区二区| 精品一区二区三区视频在线观看| 成人av电影免费在线播放| 欧美高清dvd| 国产精品私房写真福利视频| 亚洲一级二级三级在线免费观看| 久久精品国产亚洲aⅴ| 99精品视频一区二区三区| 欧美精品乱码久久久久久按摩| 久久久久久97三级| 亚洲6080在线| 99久久婷婷国产综合精品| 在线不卡欧美精品一区二区三区| 国产精品毛片久久久久久| 午夜电影网一区| 97久久超碰精品国产| 欧美日本一道本| 一区在线观看视频| 九一久久久久久| 欧美综合一区二区| 国产片一区二区三区| 视频一区视频二区中文| www.日韩精品| 精品国产露脸精彩对白| 亚洲福利一区二区三区| 欧美日本精品一区二区三区| 国产福利精品一区二区| 不卡电影免费在线播放一区| 日韩欧美色综合网站| 一区二区三区在线免费播放| 懂色一区二区三区免费观看 | 男人操女人的视频在线观看欧美| 99re这里只有精品6| 久久奇米777| 蜜臀久久99精品久久久久久9| 色国产精品一区在线观看| 中文字幕在线观看一区| 国产成人综合在线| 26uuu国产日韩综合| 免费在线观看视频一区| 欧美精品日韩一本| 亚洲成人av一区二区三区| 在线免费观看不卡av| 成人免费在线观看入口| 成人国产精品免费观看| 国产午夜精品一区二区三区视频 | 大胆欧美人体老妇| 国产欧美日本一区二区三区| 国产米奇在线777精品观看| 精品欧美乱码久久久久久| 日本三级韩国三级欧美三级| 欧美精品在欧美一区二区少妇| 一区二区三区在线视频免费| 色综合久久99| 性做久久久久久免费观看欧美| 91久久精品一区二区三区| 亚洲男同性恋视频| 91老司机福利 在线| 一区二区三区四区av| 欧美性受xxxx黑人xyx| 亚洲午夜久久久久中文字幕久| 欧美在线色视频| 亚洲第一综合色| 3d成人动漫网站| 麻豆一区二区三| 精品理论电影在线观看| 精品综合免费视频观看| 久久久精品国产免大香伊| 成人看片黄a免费看在线| 亚洲欧洲综合另类| 欧美日本韩国一区二区三区视频| 美日韩黄色大片| 国产欧美精品区一区二区三区| av中文字幕不卡| 一区二区三区日韩精品| 欧美一级免费观看| 国产乱码精品一区二区三区av| 国产女人18毛片水真多成人如厕| 91女神在线视频| 日韩精品福利网| 国产欧美日韩亚州综合| 一本大道久久精品懂色aⅴ|