1 /** 2 * Resolve the value of the 'action
' attribute. 3 *If the user configured an '
@link org.springframework.web.servlet.support.RequestContext#getRequestUri() originating URI} 6 * is used. 7 * @return the value that is to be used for the 'action
' value then 4 * the result of evaluating this value is used. Otherwise, the 5 * {action
' attribute 8 */ 9 protected String resolveAction() throws JspException {10 String action = getAction();11 if (StringUtils.hasText(action)) {12 action = getDisplayString(evaluate(ACTION_ATTRIBUTE, action));13 return processAction(action);14 }15 else {16 String requestUri = getRequestContext().getRequestUri();17 ServletResponse response = this.pageContext.getResponse();18 if (response instanceof HttpServletResponse) {19 requestUri = ((HttpServletResponse) response).encodeURL(requestUri);20 String queryString = getRequestContext().getQueryString();21 if (StringUtils.hasText(queryString)) {22 requestUri += "?" + HtmlUtils.htmlEscape(queryString);23 }24 }25 if (StringUtils.hasText(requestUri)) {26 return processAction(requestUri);27 }28 else {29 throw new IllegalArgumentException("Attribute 'action' is required. " +30 "Attempted to resolve against current request URI but request URI was null.");31 }32 }33 }
源码注释中写到,如果页面<form:form action="" method="POST">,如果action为空,则根据 getRequestUri()来设置action。