在SpringMVC的controller中,@RequestMapping只写路径,不包含RequetMethod.GET和RequetMethod.POST,HttpServletRequest的getParameter(“*”)方法同时支持这两种方式。

 @RequestMapping("savedata")
public @ResponseBody void savedata(HttpServletRequest req, HttpServletResponse resp) throws Exception { String taskClass = req.getParameter("taskclass");

ServletRequest接口中对该方法的说明如下,可以从请求字符串(URL)和POST实体(通过getInputStream和getReader方法)中读取参数:

 /**
* Returns the value of a request parameter as a <code>String</code>,
* or <code>null</code> if the parameter does not exist. Request parameters
* are extra information sent with the request. For HTTP servlets,
* parameters are contained in the query string or posted form data.
*
* <p>You should only use this method when you are sure the
* parameter has only one value. If the parameter might have
* more than one value, use {@link #getParameterValues}.
*
* <p>If you use this method with a multivalued
* parameter, the value returned is equal to the first value
* in the array returned by <code>getParameterValues</code>.
*
* <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.
*
* @param name a <code>String</code> specifying the name of the parameter
*
* @return a <code>String</code> representing the single value of
* the parameter
*
* @see #getParameterValues
*/
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

SpringMVC 控制器默认支持GET和POST两种方式的更多相关文章

  1. Nginx配置同一个域名同时支持http与https两种方式访问

    Nginx配置同一个域名http与https两种方式都可访问,证书是阿里云上免费申请的 server{listen 80;listen 443 ssl;ssl on;server_name 域名;in ...

  2. 解决springmvc拦截器拦截静态资源的两种方式

    1.是采用<mvc:default-servlet-handler />,(一般Web应用服务器默认的Servlet名称是"default",所以这里我们激活Tomca ...

  3. springMVC使用jsp:include嵌入页面的两种方式

    1.静态嵌入子页面 <%@ include file="header.jsp" %>   静态嵌入支持 jsp . html . xml 以及纯文本. 静态嵌入在编译时 ...

  4. springmvc和servlet在上传和下载文件(保持文件夹和存储数据库Blob两种方式)

    参与该项目的文件上传和下载.一旦struts2下完成,今天springmvc再来一遍.发现springmvc特别好包,基本上不具备的几行代码即可完成,下面的代码贴: FileUpAndDown.jsp ...

  5. 【Spring】SpringMVC非注解配置的两种方式

    目录结构: contents structure [+] SpringMVC是什么 Spring MVC的设计原理 SpringMVC配置的第一种方式 1,复制Jar包 2,Web.xml文件 3,M ...

  6. springmvc配置AOP的两种方式

    spingmvc配置AOP有两种方式,一种是利用注解的方式配置,另一种是XML配置实现. 应用注解的方式配置: 先在maven中引入AOP用到的依赖 <dependency> <gr ...

  7. nginx将http升级到https并且同时支持http和https两种请求、http自动转向https

    1.http升级到https 1.1.检查 Nginx 是否支持 SSL /usr/local/nginx/sbin/nginx -V configure arguments中是否有--with-ht ...

  8. Javscript轮播 支持平滑和渐隐两种效果(可以只有两张图)

    原文:Javscript轮播 支持平滑和渐隐两种效果(可以只有两张图) 先上两种轮播效果:渐隐和移动   效果一:渐隐 1 2 3 4 效果二:移动 1 2 3 4 接下来,我们来大致说下整个轮播的思 ...

  9. Javascript轮播 支持平滑和渐隐两种效果

    Javascript轮播 支持平滑和渐隐两种效果 先上两种轮播效果:渐隐和移动   效果一:渐隐 1 2 3 4 效果二:移动 1 2 3 4 接下来,我们来大致说下整个轮播的思路: 一.先来看简单的 ...

随机推荐

  1. win10解决乱码问题

    Unicode是Unicode.org制定的编码标准,目前得到了绝大部分操作系统和编程语言的支持.Unicode.org官方对Unicode的定义是:Unicode provides a unique ...

  2. json数据导出excel

    最近做的一个项目涉及到把数据导出到excel里面,网上找来找去,最终找到两种办法,废话不多说了 第一种: 拿到表格的id就可以抓取表格的数据,导出到excel,这种方式简单粗暴,引入这两个插件即可. ...

  3. OSChinaclient源代码学习(1)--Android与Server的交互

    这里主要针对"综合"这个选项卡下的"资讯"模块为样例.对核心代码进行解读. 准备工作:參考我的另外一篇博客 http://blog.csdn.net/csp27 ...

  4. YII进行数据增删改查分析

    关于模型部分參考http://blog.csdn.net/buyingfei8888/article/details/40208729 控制器部分: <?php class GoodsContr ...

  5. java多线程编程核心技术——第七章补漏拾遗

    本章主要知识点: 1)线程组的使用 2)如何切换线程状态 3)SimpleDateFormat类与多线程的解决方法 4)如何处理线程异常. 这本书基本来到了终点,其实在第四章来说,核心(基础)的线程知 ...

  6. flask 上传文件

    flask upload 近日在学习python,接触到了flask框架,刚好客户有个需求,需要在网页上传一个python 代码的zip包,然后使用docker 容器运行这个zip里面的程序,输出结果 ...

  7. 配置Meld为git的默认比较工具

    1. 安装 meld sudo apt-get install meld 2. 创建 git_meld.sh 脚本 cd /bin vim git-meld.sh #!/bin/sh meld $2 ...

  8. ATL环境:设置父窗口激活属性

    设置窗口激活属性:窗口A->B->C,这里设置在C对话框显示时A和B都不能操作 LRESULT sindykTools::AttrPOIDlg::OnBatchCreateSubPoint ...

  9. 《金领简历:敲开苹果、微软、谷歌的大门》【PDF】下载

    <金领简历:敲开苹果.微软.谷歌的大门>[PDF]下载链接: https://u253469.ctfile.com/fs/253469-231196331 内容简介 <金领简历:敲开 ...

  10. JavaScript类型比较

    JavaScript的类型 原始类型: number string boolean null undefined 对象类型: Object function Array Date ... 隐式转换 + ...