📄 actiontag.java
字号:
/* * WebWork, Web Application Framework * * Distributable under Apache license. * See terms of license at opensource.org */package webwork.view.taglib;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.jsp.JspException;import javax.servlet.jsp.PageContext;import org.apache.commons.logging.*;import webwork.action.ActionContext;import webwork.action.ServletActionContext;import webwork.dispatcher.GenericDispatcher;import java.security.Principal;/** * Instantiate an Action and execute it. * It is lazily executed, which means that you can set parameters * by using the "param" tag. * * @author Rickard 謆erg (rickard@dreambean.com) * @version $Revision: 1.19 $ */public class ActionTag extends BeanTag { protected static Log log = LogFactory.getLog(ActionTag.class); GenericDispatcher gd; // BodyTag implementation ---------------------------------------- public int doStartTag() throws JspException { String name = (String) findValue(nameAttr); if (name == null) throw new JspException("No action named " + nameAttr + " found. Try putting quotes around name"); Principal oldPrincipal = ActionContext.getPrincipal(); gd = new GenericDispatcher(name, true); ActionContext context = gd.prepareContext(); ServletActionContext.setContext((HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse(), pageContext.getServletContext(), name); gd.prepareValueStack(); ActionContext.setPrincipal(oldPrincipal); try { gd.executeAction(); bean = gd.getActions().get(0); } catch (Throwable t) { String msg = "Caught throwable when instantiating action: " + name; log.error(msg, t); throw new JspException(msg + ", throwable: " + t); } if (getId() != null) { pageContext.setAttribute(getId(), bean); pageContext.setAttribute(getId(), bean, PageContext.REQUEST_SCOPE); } return EVAL_BODY_INCLUDE; } public int doEndTag() throws JspException { gd.finish(); gd.finalizeContext(); return EVAL_PAGE; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -