SpringMVC 控制器默认支持GET和POST两种方式
在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两种方式的更多相关文章
- Nginx配置同一个域名同时支持http与https两种方式访问
Nginx配置同一个域名http与https两种方式都可访问,证书是阿里云上免费申请的 server{listen 80;listen 443 ssl;ssl on;server_name 域名;in ...
- 解决springmvc拦截器拦截静态资源的两种方式
1.是采用<mvc:default-servlet-handler />,(一般Web应用服务器默认的Servlet名称是"default",所以这里我们激活Tomca ...
- springMVC使用jsp:include嵌入页面的两种方式
1.静态嵌入子页面 <%@ include file="header.jsp" %> 静态嵌入支持 jsp . html . xml 以及纯文本. 静态嵌入在编译时 ...
- springmvc和servlet在上传和下载文件(保持文件夹和存储数据库Blob两种方式)
参与该项目的文件上传和下载.一旦struts2下完成,今天springmvc再来一遍.发现springmvc特别好包,基本上不具备的几行代码即可完成,下面的代码贴: FileUpAndDown.jsp ...
- 【Spring】SpringMVC非注解配置的两种方式
目录结构: contents structure [+] SpringMVC是什么 Spring MVC的设计原理 SpringMVC配置的第一种方式 1,复制Jar包 2,Web.xml文件 3,M ...
- springmvc配置AOP的两种方式
spingmvc配置AOP有两种方式,一种是利用注解的方式配置,另一种是XML配置实现. 应用注解的方式配置: 先在maven中引入AOP用到的依赖 <dependency> <gr ...
- nginx将http升级到https并且同时支持http和https两种请求、http自动转向https
1.http升级到https 1.1.检查 Nginx 是否支持 SSL /usr/local/nginx/sbin/nginx -V configure arguments中是否有--with-ht ...
- Javscript轮播 支持平滑和渐隐两种效果(可以只有两张图)
原文:Javscript轮播 支持平滑和渐隐两种效果(可以只有两张图) 先上两种轮播效果:渐隐和移动 效果一:渐隐 1 2 3 4 效果二:移动 1 2 3 4 接下来,我们来大致说下整个轮播的思 ...
- Javascript轮播 支持平滑和渐隐两种效果
Javascript轮播 支持平滑和渐隐两种效果 先上两种轮播效果:渐隐和移动 效果一:渐隐 1 2 3 4 效果二:移动 1 2 3 4 接下来,我们来大致说下整个轮播的思路: 一.先来看简单的 ...
随机推荐
- JaveScript变量的简介及其变量的简单使用(JS知识点归纳一)
变量简介 "变量是一个容器" 为什么要有变量? 程序的执行过程中,会使用到许多的数据(用户输入的内容,动态效果的运动数据等),当这些数据需要重复在多个地方使用的时候,就需要一个容器 ...
- 深入浅出了解frame和bounds
frame frame的官方解释如下: The frame rectangle, which describes the view's location and size in its supervi ...
- cocos2d-x3.6 连连看完整源代码
我的博客:http://blog.csdn.net/dawn_moon 好了,这个连连看是用最新版cocos2d-x 3.6版写的,里面使用了非常多新特性. 基本完工了.另一个积分和关卡没有做.有兴趣 ...
- 十三、 Spring Boot 启动加载数据 CommandLineRunner
实际应用中,我们会有在项目服务启动的时候就去加载一些数据或做一些事情这样的需求. 为了解决这样的问题,spring Boot 为我们提供了一个方法,通过实现接口 CommandLineRunner 来 ...
- 聊聊js中的typeof
内容: 1.typeof 2.值类型和引用类型 3.强制类型转换 typeof 官方文档:typeof 1.作用: 操作符返回一个字符串,指示未经计算的操作数的类型. 2.语法: typeof ope ...
- CS:APP3e 深入理解计算机系统_3e ShellLab(tsh)实验
详细的题目要求和资源可以到 http://csapp.cs.cmu.edu/3e/labs.html 或者 http://www.cs.cmu.edu/~./213/schedule.html 获取. ...
- MyBatis学习总结——实现关联表查询(转)
原文链接:孤傲苍狼 一.一对一关联 1.1.提出需求 根据班级id查询班级信息(带老师的信息) 1.2.创建表和数据 创建一张教师表和班级表,这里我们假设一个老师只负责教一个班,那么老师和班级之间的关 ...
- 工作随笔——ember框架去除url上的#号
因为工作原因,接触到了一套非常好的前端框架--ember. ember框架高度封装,学习曲线比较陡峭. ember对于url更新的配置在config/environment.js >> l ...
- 《Java并发编程实战》/童云兰译【PDF】下载
<Java并发编程实战>/童云兰译[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230062521 内容简介 本书深入浅出地介绍了Jav ...
- 《深入理解Java虚拟机:JVM高级特性与最佳实践》【PDF】下载
<深入理解Java虚拟机:JVM高级特性与最佳实践>[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230062566 内容简介 作为一位 ...