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

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

?? myfreemarkerresult.java

?? JAVA做的CMS源碼
?? JAVA
字號(hào):
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
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕在线观看不卡视频| 久久欧美一区二区| 亚洲韩国精品一区| 在线观看一区二区视频| 亚洲国产aⅴ成人精品无吗| 欧美精品 国产精品| 国产精品一区专区| 日韩理论电影院| 欧美日精品一区视频| 日产国产欧美视频一区精品| 久久久久国色av免费看影院| 91麻豆国产在线观看| 天天色综合成人网| 久久亚洲综合色| av不卡免费在线观看| 午夜视频一区在线观看| 久久一日本道色综合| 99精品视频一区| 日韩黄色片在线观看| 久久久美女艺术照精彩视频福利播放| 99视频国产精品| 日本少妇一区二区| 中文字幕不卡三区| 91麻豆精品国产自产在线观看一区 | 亚洲一区二区在线视频| 欧美男同性恋视频网站| 国产盗摄女厕一区二区三区| 亚洲精品国产无套在线观| 欧美一区二区三区精品| 福利视频网站一区二区三区| 亚洲成人免费电影| 国产三级精品在线| 欧美三级三级三级| 成人美女在线观看| 美国十次综合导航| 亚洲老司机在线| 久久综合五月天婷婷伊人| 精品视频全国免费看| 成人中文字幕电影| 久久99久久99| 日韩一区欧美二区| 亚洲你懂的在线视频| 国产亚洲一区二区三区| 欧美日韩国产精选| 91丨porny丨在线| 国产米奇在线777精品观看| 亚洲一区二区精品3399| 国产精品久久久久久久蜜臀 | 久久久91精品国产一区二区精品| 日本高清视频一区二区| 粉嫩一区二区三区在线看| 免费久久精品视频| 午夜视频在线观看一区二区| 亚洲欧洲日韩一区二区三区| 久久久亚洲国产美女国产盗摄| 91精品婷婷国产综合久久竹菊| 91免费在线看| 成人网在线播放| 国产激情一区二区三区桃花岛亚洲| 蜜桃视频在线观看一区| 午夜欧美一区二区三区在线播放| ...xxx性欧美| 成人欧美一区二区三区白人| 国产精品三级电影| 国产日韩精品一区二区三区 | 欧美人与禽zozo性伦| 99re成人在线| 91麻豆免费看片| 色婷婷久久久综合中文字幕| eeuss影院一区二区三区| 成人久久久精品乱码一区二区三区| 国产精品一区二区不卡| 狠狠色狠狠色综合| 精品在线观看免费| 另类小说视频一区二区| 蜜桃久久精品一区二区| 蜜臀av性久久久久蜜臀av麻豆| 日韩电影在线看| 久久精品72免费观看| 狠狠色综合日日| 成人一区二区三区视频| 成人蜜臀av电影| 日本韩国欧美一区| 欧美日韩精品一区二区天天拍小说| 欧美日韩国产精品成人| 日韩一级精品视频在线观看| 精品美女在线观看| 久久久久久一二三区| 国产精品你懂的在线欣赏| 中文字幕一区视频| 亚洲一级二级三级在线免费观看| 午夜精品久久久久久不卡8050 | 久久国产精品露脸对白| 国产大片一区二区| 91在线视频官网| 在线成人免费视频| www久久久久| 国产精品不卡在线| 亚洲一区二区五区| 国精产品一区一区三区mba桃花| 大陆成人av片| 欧美视频中文一区二区三区在线观看 | 精品福利在线导航| 国产午夜精品理论片a级大结局| 国产精品不卡视频| 亚洲成av人片一区二区三区| 美腿丝袜亚洲综合| 99久久99久久免费精品蜜臀| 欧美午夜不卡在线观看免费| 精品乱人伦一区二区三区| 国产精品美女一区二区三区 | www.亚洲人| 欧美日韩一二三区| 久久久久国产精品厨房| 亚洲综合色丁香婷婷六月图片| 日韩电影免费一区| 成年人午夜久久久| 日韩三级电影网址| 最新热久久免费视频| 欧美aaaaa成人免费观看视频| 不卡av电影在线播放| 3d动漫精品啪啪一区二区竹菊 | 91久久奴性调教| 精品毛片乱码1区2区3区| 亚洲美女精品一区| 黑人精品欧美一区二区蜜桃| 在线视频观看一区| 久久久国际精品| 亚洲va欧美va人人爽| 99在线精品免费| 久久久91精品国产一区二区精品 | 国产精品久久久久久久久图文区| 亚洲v日本v欧美v久久精品| 成人午夜精品一区二区三区| 欧美mv日韩mv| 日日夜夜精品视频免费| 91视频国产观看| 国产视频一区在线观看| 肉色丝袜一区二区| 欧美少妇性性性| 洋洋成人永久网站入口| 粉嫩一区二区三区性色av| 精品剧情在线观看| 日韩高清电影一区| 欧美日韩在线亚洲一区蜜芽| 亚洲精品中文在线| 99国产精品久久久久久久久久久| 国产日韩欧美一区二区三区乱码| 麻豆国产欧美一区二区三区| 欧美久久高跟鞋激| 婷婷成人激情在线网| 欧美专区亚洲专区| 亚洲自拍欧美精品| 91国产福利在线| 亚洲嫩草精品久久| 91搞黄在线观看| 1024精品合集| 色综合久久久久久久| 亚洲欧洲在线观看av| av电影天堂一区二区在线观看| 国产日韩欧美高清在线| 国产成人av电影在线观看| 久久久久免费观看| 国产aⅴ综合色| 日本一二三四高清不卡| 波多野结衣精品在线| 国产精品不卡视频| 日本韩国精品在线| 亚洲国产日韩精品| 欧美日韩在线播放三区| 天天影视网天天综合色在线播放| 欧美日韩亚洲另类| 日本强好片久久久久久aaa| 91精品麻豆日日躁夜夜躁| 蜜臀av一级做a爰片久久| 精品福利在线导航| 成人深夜视频在线观看| 亚洲欧美偷拍卡通变态| 欧美日韩精品一区二区三区| 蜜臀av性久久久久蜜臀aⅴ四虎 | 日韩欧美在线123| 麻豆免费看一区二区三区| 久久久久久久久蜜桃| 成人午夜免费av| 亚洲午夜久久久久久久久电影网| 欧美另类变人与禽xxxxx| 久草中文综合在线| 国产精品久久久久久妇女6080 | 麻豆精品视频在线观看视频| 久久品道一品道久久精品| 成人黄色国产精品网站大全在线免费观看 | 色欧美日韩亚洲| 日欧美一区二区| 久久久午夜电影| 在线日韩av片| 国产一区二区精品久久| 亚洲免费看黄网站| 日韩视频免费观看高清完整版在线观看 | 久久九九影视网| 欧美色倩网站大全免费|