Author: jholmes Date: Tue Jul 31 18:08:36 2007 New Revision: 561617 URL: http://svn.apache.org/viewvc?view=rev&rev=561617 Log: Log a warning if user specifies a namespace and action with the <s:form> tag and the action is not found in the namespace. Right now this fails silently and the user gets an HTTP 404 typically. I've had this happen to me and it took a little while to realize I had the wrong namespace or action name. This warning should help users figure out the issue faster by giving them a heads up.
Modified: struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/Form.java Modified: struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/Form.java URL: http://svn.apache.org/viewvc/struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/Form.java?view=diff&rev=561617&r1=561616&r2=561617 ============================================================================== --- struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/Form.java (original) +++ struts/struts2/branches/STRUTS_2_0_X/core/src/main/java/org/apache/struts2/components/Form.java Tue Jul 31 18:08:36 2007 @@ -29,6 +29,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.struts2.views.annotations.StrutsTag; import org.apache.struts2.views.annotations.StrutsTagAttribute; import org.apache.struts2.StrutsConstants; @@ -95,6 +97,11 @@ */ @StrutsTag(name="form", tldTagClass="org.apache.struts2.views.jsp.ui.FormTag", description="Renders an input form") public class Form extends ClosingUIBean { + /** + * Provide a logging instance. + */ + private static final Log LOG = LogFactory.getLog(Form.class); + public static final String OPEN_TEMPLATE = "form"; public static final String TEMPLATE = "form-close"; @@ -292,8 +299,14 @@ } } else if (action != null) { // Since we can't find an action alias in the configuration, we just assume - // the action attribute supplied is the path to be used as the uri this + // the action attribute supplied is the path to be used as the URI this // form is submitting to. + + // Warn user that the specified namespace/action combo + // was not found in the configuration. + if (namespace != null) { + LOG.warn("No configuration found for the specified action: '" + action + "' in namespace: '" + namespace + "'. Form action defaulting to 'action' attribute's literal value."); + } String result = UrlHelper.buildUrl(action, request, response, null); addParameter("action", result);