Action:
package action;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.interceptor.ApplicationAware;
import org.apache.struts2.interceptor.ParameterAware;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class BasicAction extends ActionSupport implements ParameterAware,
ServletRequestAware, ServletResponseAware, SessionAware,
ApplicationAware {
@Override
public void setApplication(Map
}
@Override
public void setSession(Map
//ActionContext.getContext().getSession();
}
@Override
public void setServletResponse(HttpServletResponse arg0) {
}
@Override
public void setServletRequest(HttpServletRequest arg0) {
//ActionContext.getContext().get("request");
}
@Override
public void setParameters(Map
}
}
converter:
package converter;
import java.awt.List;
import java.lang.reflect.Member;
import java.util.Arrays;
import java.util.Map;
import ognl.DefaultTypeConverter;
public class DateConvert extends DefaultTypeConverter {
@SuppressWarnings("rawtypes")
@Override
public Object convertValue(Map context, Object value, Class toType) {
if (toType == List.class)
{
return Arrays.asList(value);
}
return super.convertValue(context, value, toType);
}
@SuppressWarnings("rawtypes")
@Override
public Object convertValue(Map context, Object target, Member member,
String propertyName, Object value, Class toType) {
return super.convertValue(context, target, member, propertyName, value, toType);
}
}
interceptor:
package interceptor;
import java.util.Map;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
@SuppressWarnings("serial")
public class BasicInterceptor extends AbstractInterceptor {
@Override
public String intercept(ActionInvocation arg0) throws Exception {
Map
if (null != session) {
// TODO
return arg0.invoke();
}
else{
return Action.LOGIN;
}
}
}