redirect.java

来自「webwork source」· Java 代码 · 共 73 行

JAVA
73
字号
/* * WebWork, Web Application Framework * * Distributable under Apache license. * See terms of license at opensource.org */package webwork.action.standard;import webwork.action.ActionSupport;import webwork.action.ServletResponseAware;import webwork.action.CommandDriven;import webwork.action.ResultException;import javax.servlet.http.HttpServletResponse;/** *	Redirect to a given URL. Do not map any view to this action. * *	@see <related> *	@author Rickard 謆erg (rickard@middleware-company.com) *	@version $Revision: 1.11 $ */public class Redirect   extends ActionSupport   implements ServletResponseAware{   // Attributes ----------------------------------------------------   String url;   HttpServletResponse response;   // Static --------------------------------------------------------   // Implements ServletResponseAware -------------------------------   public void setServletResponse(HttpServletResponse aResponse)   {      response = aResponse;   }   // Public --------------------------------------------------------   /**    * URL to redirect to    */   public void setUrl(String aUrl)   {      url = aUrl;   }   public String getUrl()   {      return url;   }    protected void validate() throws ResultException {        //don't do anything - this keeps it from failing to redirect if the action it is chained from has errors    }   // Action implementation -----------------------------------------   /**    * Redirect to URL    */   protected String doExecute()      throws Exception   {      if (url == null)        return ERROR;      url = response.encodeUrl(url);      response.sendRedirect(url);      return NONE;   }}

⌨️ 快捷键说明

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