Skip to content

Instantly share code, notes, and snippets.

@roundrop
Created June 24, 2013 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roundrop/5849305 to your computer and use it in GitHub Desktop.
Save roundrop/5849305 to your computer and use it in GitHub Desktop.
org.apache.struts.action.ExceptionHandler の拡張。 これをglobal-exceptionsのhandlerに使用することで、pathにSAStrutsが認識するパスをそのまま記述することが可能となる。
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ExceptionHandler;
import org.apache.struts.config.ExceptionConfig;
import org.seasar.struts.config.S2ActionMapping;
public class S2ExceptionHandler extends ExceptionHandler {
@Override
public ActionForward execute(Exception exception, ExceptionConfig config,
ActionMapping mapping, ActionForm formInstance,
HttpServletRequest request, HttpServletResponse response)
throws ServletException {
return (config.getPath() != null
? ((S2ActionMapping) mapping).createForward(config.getPath())
: mapping.getInputForward());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment