SpringMVC 控制器默认支持GET和POST两种方式
在SpringMVC的controller中,@RequestMapping只写路径,不包含RequetMethod.GET和RequetMethod.POST,HttpServletRequest的getParameter(“*”)方法同时支持这两种方式。
1 @RequestMapping("savedata") 2 public @ResponseBody void savedata(HttpServletRequest req, HttpServletResponse resp) throws Exception { 3 4 String taskClass = req.getParameter("taskclass");
ServletRequest接口中对该方法的说明如下,可以从请求字符串(URL)和POST实体(通过getInputStream和getReader方法)中读取参数:
1 /** 2 * Returns the value of a request parameter as a <code>String</code>, 3 * or <code>null</code> if the parameter does not exist. Request parameters 4 * are extra information sent with the request. For HTTP servlets, 5 * parameters are contained in the query string or posted form data. 6 * 7 * <p>You should only use this method when you are sure the 8 * parameter has only one value. If the parameter might have 9 * more than one value, use {@link #getParameterValues}. 10 * 11 * <p>If you use this method with a multivalued 12 * parameter, the value returned is equal to the first value 13 * in the array returned by <code>getParameterValues</code>. 14 * 15 * <p>If the parameter data was sent in the request body, such as occurs 16 * with an HTTP POST request, then reading the body directly via {@link 17 * #getInputStream} or {@link #getReader} can interfere 18 * with the execution of this method. 19 * 20 * @param name a <code>String</code> specifying the name of the parameter 21 * 22 * @return a <code>String</code> representing the single value of 23 * the parameter 24 * 25 * @see #getParameterValues 26 */ 27 public String getParameter(String name);
参考:
http://tomcat.apache.org/tomcat-5.5-doc/servletapi/index.html
http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc-ann-requestmapping
转载于:https://www.cnblogs.com/shuimuzhushui/p/7255347.html
SpringMVC 控制器默认支持GET和POST两种方式相关推荐
- POI读取word文件,(支持HSSF和XSSF两种方式)
POI读取word文件,(支持HSSF和XSSF两种方式) 参考:HSSF,XSSF,SXSSF三种方式 1.引用maven(版本必须一致) <dependency><groupId ...
- spring支持事务管理的两种方式
转载:https://blog.csdn.net/bao19901210/article/details/41724355 事物管理对于企业应用来说是至关重要的,好使出现异常情况,它也可以保证数据的一 ...
- Nginx配置同一个域名同时支持http与https两种方式访问
Nginx配置同一个域名http与https两种方式都可访问,证书是阿里云上免费申请的 server { listen 80; listen 443 ssl; ssl on; server_name ...
- springmvc配置同时支持html和jspl两种格式的页面
通常情况下,springmvc返回一种格式的文件,通过配置前缀和后缀,相应controller层只需返回字符串,就可以跳转到相关页面. 有时候,项目中html和jsp页面同时存在,如果不做特殊配置,需 ...
- Cesium 修改默认地球贴图的两种方式
Cesium 建立Cesium.Viewer的时候,默认的贴图(imageryProviderViewModels)为'Bing Maps Aerial',但是因为"HTTP401: 已拒绝 ...
- CMAKE支持c++11的两种方式
全局设置 set (CMAKE_CXX_STANDARD 11) 注意:这种方式仅适用于cmake3.1之后 如果是老版本,稍微麻烦一些 include(CheckCXXCompilerFlag) C ...
- Nginx配置同时支持http和https两种方式访问
http: https: Nginx的ssl模块安装 进入到目录的sbin目录下,输入 #注意这里是大写的V,小写的只显示版本号 ./nginx -V 如果出现 (configure argument ...
- 基于Netty手工实现springMVC框架-----两种方式加载控制器
1.手写springMVC框架 本篇我们通过两种方式来加载控制器,一种是配置文件的方式:另外一种是通过注解的形式. 1.配置文件方式 1.自定义Controller配置文件XML 我定义的格式如下: ...
- NVMe协议逻辑实现、nvme固态硬盘,支持master和slave两种模式,FPGA、SSD控制器,接口统一标准化、简单方便
NVMe协议逻辑实现.nvme固态硬盘,支持master和slave两种模式,FPGA.SSD控制器,接口统一标准化.简单方便. 1.支持admin和nvme命令集. 2.支持随机和顺序读写,顺序读写 ...
最新文章
- idea工具使用总结
- 如何根据ABAP类的一个方法名称,反查出这个类的名称
- python html压缩包,用python制作一个简单html压缩
- 《Genesis-3D开源游戏引擎--横版格斗游戏制作教程03:碰撞检测》
- 新员工犯错续:解决问题
- HTML5 Web Audio Api-2 发声oscillator
- 开源的XAG迈向新征程
- 二十四孝{做人不孝无异于禽兽,请宏扬我中华美德!}组图
- 英文产品网站的搜索引擎推广
- 初步认识一下余弦定理余余弦相似度
- Symbian OS内存管理介绍
- TeXworks文献引用问题
- 十分钟读懂『K-Means 算法』
- css实现文字从右向左排列
- HTML5学习(07)文档/段落
- CentOS开发环境工具安装汇总
- java国际化英语_Java国际化(i18n)UTC
- VVC DRAP帧和EDRAP帧,STSA picture
- 在多媒体计算机中声音信息处理后,第3章音频、视频的信息处理.ppt
- Oracle导出Excel的几种操作方案的比较
热门文章
- Unity3D中关于场景销毁时事件调用顺序的一点记录
- centos7安装gitlab7.5.0
- eclipse 优化。
- 图像处理基本概念——卷积,滤波,平滑
- Java_String
- 关于C/C++中的几个关键字(C基础)
- 最近实在抽不出时间更新博客
- Java网络编程之SocketChannel和ServerSocketChannel
- Redis主从复制、哨兵模式和分布式集群
- curl -s http://192.168.232.191/openapi/v2 | jq 不显示JSON格式的文档说明