博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SpringMVC FormTag resolve action
阅读量:4319 次
发布时间:2019-06-06

本文共 1741 字,大约阅读时间需要 5 分钟。

1 /** 2      * Resolve the value of the 'action' attribute. 3      * 

If the user configured an 'action' 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 '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。

转载于:https://www.cnblogs.com/helloxc/p/4062271.html

你可能感兴趣的文章
linux uniq 命令
查看>>
Openssl rand命令
查看>>
HDU2825 Wireless Password 【AC自动机】【状压DP】
查看>>
BZOJ1015: [JSOI2008]星球大战starwar【并查集】【傻逼题】
查看>>
HUT-XXXX Strange display 容斥定理,线性规划
查看>>
mac修改用户名
查看>>
一道关于员工与部门查询的SQL笔试题
查看>>
Canvas基础
查看>>
[Hive - LanguageManual] Alter Table/Partition/Column
查看>>
可持久化数组
查看>>
去除IDEA报黄色/灰色的重复代码的下划波浪线
查看>>
Linux发送qq、网易邮件服务配置
查看>>
几道面试题
查看>>
【转】使用 WebGL 进行 3D 开发,第 1 部分: WebGL 简介
查看>>
js用正则表达式控制价格输入
查看>>
chromium浏览器开发系列第三篇:chromium源码目录结构
查看>>
java开发操作系统内核:由实模式进入保护模式之32位寻址
查看>>
第五讲:单例模式
查看>>
Python编程语言的起源
查看>>
Azure ARMTemplate模板,VM扩展命令
查看>>