标签:style blog http io color os ar for sp
1 /** 2 * Resolve the value of the ‘<code>action</code>‘ attribute. 3 * <p>If the user configured an ‘<code>action</code>‘ value then 4 * the result of evaluating this value is used. Otherwise, the 5 * {@link org.springframework.web.servlet.support.RequestContext#getRequestUri() originating URI} 6 * is used. 7 * @return the value that is to be used for the ‘<code>action</code>‘ 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。
SpringMVC FormTag resolve action
标签:style blog http io color os ar for sp
原文地址:http://www.cnblogs.com/helloxc/p/4062271.html