Search in sources :

Example 6 with ActionContext

use of com.opensymphony.xwork2.ActionContext in project bamboobsc by billchen198318.

the class ActionInfoSupportInterceptor method intercept.

@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
    /*
		ActionInvocation ai=(ActionInvocation)ActionContext.getContext().get(ActionContext.ACTION_INVOCATION); 
		String action=ai.getProxy().getActionName(); 
		String namespace=ai.getProxy().getNamespace();
		*/
    HttpServletRequest request = ServletActionContext.getRequest();
    ActionContext context = actionInvocation.getInvocationContext();
    String action = actionInvocation.getProxy().getActionName();
    String namespace = actionInvocation.getProxy().getNamespace();
    String remoteAddr = request.getRemoteAddr();
    String referer = request.getHeader("referer");
    context.getSession().put(Constants.SESS_PAGE_INFO_ACTION_ByInterceptor, action);
    context.getSession().put(Constants.SESS_PAGE_INFO_NAMESPACE_ByInterceptor, namespace);
    context.getSession().put(Constants.SESS_PAGE_INFO_RemoteAddr_ByInterceptor, remoteAddr);
    context.getSession().put(Constants.SESS_PAGE_INFO_Referer_ByInterceptor, referer);
    return actionInvocation.invoke();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ActionContext(com.opensymphony.xwork2.ActionContext) ServletActionContext(org.apache.struts2.ServletActionContext)

Example 7 with ActionContext

use of com.opensymphony.xwork2.ActionContext in project bamboobsc by billchen198318.

the class JsonOutermostBracketsInterceptor method intercept.

@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
    ActionContext context = actionInvocation.getInvocationContext();
    HttpServletResponse response = (HttpServletResponse) context.get(StrutsStatics.HTTP_RESPONSE);
    response.setCharacterEncoding("utf8");
    response.setContentType("text/html");
    PrintWriter writer = response.getWriter();
    writer.print("[");
    writer.flush();
    String forward = actionInvocation.invoke();
    writer.print("]");
    writer.flush();
    return forward;
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) ActionContext(com.opensymphony.xwork2.ActionContext) PrintWriter(java.io.PrintWriter)

Aggregations

ActionContext (com.opensymphony.xwork2.ActionContext)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 ServletActionContext (org.apache.struts2.ServletActionContext)2 GreenStepBaseUsernamePasswordToken (com.netsteadfast.greenstep.sys.GreenStepBaseUsernamePasswordToken)1 AccountVO (com.netsteadfast.greenstep.vo.AccountVO)1 ValidationAware (com.opensymphony.xwork2.ValidationAware)1 ValueStack (com.opensymphony.xwork2.util.ValueStack)1 PrintWriter (java.io.PrintWriter)1 Collections.emptyMap (java.util.Collections.emptyMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Subject (org.apache.shiro.subject.Subject)1