首页 > 代码库 > SpringMVC FormTag resolve action
SpringMVC FormTag resolve action
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。