📄 domainnameinterceptor.java
字号:
package com.ponyjava.common.struts2.interceptor;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.StrutsStatics;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
@SuppressWarnings("serial")
public class DomainNameInterceptor extends MethodFilterInterceptor {
@Override
protected String doIntercept(ActionInvocation invocation) throws Exception {
Object action = invocation.getAction();
ActionContext ctx = invocation.getInvocationContext();
HttpServletRequest req = (HttpServletRequest) ctx
.get(StrutsStatics.HTTP_REQUEST);
req.setAttribute(DomainNameAware.DOMAIN_NAME, req.getServerName());
if (action instanceof DomainNameAware) {
DomainNameAware aware = (DomainNameAware) action;
aware.setDomainName(req.getServerName());
}
return invocation.invoke();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -