📄 servletredirectresult.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: ServletRedirectResult.java
package org.apache.struts2.dispatcher;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.dispatcher.mapper.ActionMapper;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
// Referenced classes of package org.apache.struts2.dispatcher:
// StrutsResultSupport, Dispatcher
public class ServletRedirectResult extends StrutsResultSupport
{
private static final long serialVersionUID = 0x57aa4e24991f5f96L;
private static final Log log = LogFactory.getLog(org/apache/struts2/dispatcher/ServletRedirectResult);
protected boolean prependServletContext;
protected ActionMapper actionMapper;
public ServletRedirectResult()
{
prependServletContext = true;
}
public ServletRedirectResult(String location)
{
super(location);
prependServletContext = true;
}
public void setActionMapper(ActionMapper mapper)
{
actionMapper = mapper;
}
public void setPrependServletContext(boolean prependServletContext)
{
this.prependServletContext = prependServletContext;
}
protected void doExecute(String finalLocation, ActionInvocation invocation)
throws Exception
{
ActionContext ctx = invocation.getInvocationContext();
HttpServletRequest request = (HttpServletRequest)ctx.get("com.opensymphony.xwork2.dispatcher.HttpServletRequest");
HttpServletResponse response = (HttpServletResponse)ctx.get("com.opensymphony.xwork2.dispatcher.HttpServletResponse");
if (isPathUrl(finalLocation))
{
if (!finalLocation.startsWith("/"))
{
ActionMapping mapping = actionMapper.getMapping(request, Dispatcher.getInstance().getConfigurationManager());
String namespace = null;
if (mapping != null)
namespace = mapping.getNamespace();
if (namespace != null && namespace.length() > 0 && !"/".equals(namespace))
finalLocation = (new StringBuilder()).append(namespace).append("/").append(finalLocation).toString();
else
finalLocation = (new StringBuilder()).append("/").append(finalLocation).toString();
}
if (prependServletContext && request.getContextPath() != null && request.getContextPath().length() > 0)
finalLocation = (new StringBuilder()).append(request.getContextPath()).append(finalLocation).toString();
finalLocation = response.encodeRedirectURL(finalLocation);
}
if (log.isDebugEnabled())
log.debug((new StringBuilder()).append("Redirecting to finalLocation ").append(finalLocation).toString());
response.sendRedirect(finalLocation);
}
private static boolean isPathUrl(String url)
{
return url.indexOf(':') == -1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -