1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
public class GenericAction extends DispatchAction
{
public static String FORWARD_DEFAULT = "default";
public static String FORWARD_ERROR = "error";
public ActionForward forward = null;
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
String parameterName = null;
String methodName = null;
try
{
parameterName = mapping.getParameter();
if ( parameterName == null ) throw new IllegalArgumentException("illegal parameter");
// Contrôle de l'appel : interdit l'utilisation de execute ou perform
methodName = request.getParameter(parameterName);
if ( methodName != null && ("execute".equals(methodName) || "perform".equals(methodName)) )
{
throw new IllegalArgumentException("illegal parameter");
}
forward = super.execute(mapping, form, request, response);
}
catch (Throwable t)
{
forward = mapping.findForward(FORWARD_ERROR);
}
return forward;
}
} |
Partager