GET

平时网页的一些基本的URL都是GET请求的,用于执行查询操作。
但是由于GET中URL是有长度的限制的,而GET会把所有的参数都放在URL中

因此就会有下面的问题:
  • 1 数据都明文暴露,用户可以直接看到
  • 2 数据长度有限制

POST

由于上面GET的缺点,POST正好弥补了这些问题。POST方法把数据都存放在body里面,这样即突破了长度的限制;又保证用户无法直接看到。在使用表单时,比较常用

HEAD

HEAD请求只会返回首部的信息,不会返回相应体。通常用于测试数据是否存在、当做心跳检测等等。

PUT

与GET相反,用于改变某些内容。

DELETE

删除某些资源

TRACE

可以理解成,我们为了看看一条请求在到达服务前数据发生了什么变化。可以使用这个命令,它会在最后一站返回原始信息,这样就可以观察到中间是否修改过请求。(经常会用于跨站攻击,所以有一定的安全隐患)

OPTIONS

询问服务器支持的方法。

PATCH

这个方法不太常见,是servlet 3.0提供的方法,主要用于更新部分字段。与PUT方法相比,PUT提交的相当于全部数据的更新,类似于update;而PATCH则相当于更新部分字段,如果数据不存在则新建,有点类似于neworupdate。

配置文件承接一二章

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello World</title>
</head>
<body>
<form action="springMVC/testMethod" method="post">
<input type="text" name="name"/>
<input type="submit" value="submit"/>
</form> <form action="springMVC/testGetMethod" method="get">
<input type="text" name="name"/>
<input type="submit" value="submitGet"/>
</form> </body>
</html>

test.java

package com.hdxy.domian;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
/**
* @author 流年拓荒者
*
*/
@RequestMapping("springMVC")
@Controller
public class Test {
final public String SUCCESS="loginSuccess";
/*常用: 使用method 属性来指定请求方式
* */
@RequestMapping(value="testMethod",method=RequestMethod.POST)
public String test3Method(String name){
System.out.println("testMethod"+name);
return SUCCESS;
} @RequestMapping(value="testGetMethod",method=RequestMethod.GET)
public String test3GetMethod(String name){
System.out.println("testGetMethod"+name);
return SUCCESS;
}
@RequestMapping(value="testGetMethod",method={RequestMethod.GET,RequestMethod.POST})
public String test3PostGetMethod(String name){
System.out.println("testGetPostMethod"+name);
return SUCCESS;
}
}

SpringMVC---Method的更多相关文章

  1. SpringMVC method属性与http请求方法一致

    在springMVC中,@requestMapping注解有method属性,在没有指定method的值时,默认映射所有http请求方法,如果仅想接收一种请求方法,需用method=RequestMe ...

  2. SpringMVC框架出现 405 request method post not supported 的解决方法

    在SpringMVC框架中当使用post请求服务,然后请求成功转到一个静态文件,如html,htm等网页时.页面出现405 request method post not supported错误,只要 ...

  3. springmvc访问静态资源出现Request method 'GET' not supported

    答案最后.:D 默认的访问的URL都会被DispatcherServlet所拦截. 这里说一下如何配置springmvc访问静态文件. <mvc:default-servlet-handler/ ...

  4. springMVC出现HTTP Status 405 - Request method 'GET' not supported错误的解决方法

    今天在写一个简单的springMVC的表单请求处理时,出现了这个问题.我的form表单用的是post方法提交,并没有使用get方法,出现这个问题时,笔者可谓是一脸懵逼. 这是form表单: 这是对po ...

  5. SpringMVC“Ambiguous mapping found. Cannot map 'XXXController' bean method”解决方法

    [转 :http://www.fanfanyu.cn/news/staticpagefile/2351.html] 最近在开发项目的过程中SpringMVC抛了个"Ambiguous map ...

  6. Springmvc的handler method参数绑定常用的注解

    转自:http://blog.longjiazuo.com/archives/1149   1. 简介: handler method参数绑定常用的注解,我们根据他们处理的Request的不同内容部分 ...

  7. SpringMVC项目中获取所有URL到Controller Method的映射

    Spring是一个很好很强大的开源框架,它就像是一个容器,为我们提供了各种Bean组件和服务.对于MVC这部分而言,它里面实现了从Url请求映射控制器方法的逻辑处理,在我们平时的开发工作中并不需要太多 ...

  8. 使用SpringMVC时报错HTTP Status 405 - Request method 'GET' not supported

    GET方法不支持.我出错的原因在于,在JSP中我希望超链接a以post方式提交,但是这里写js代码时出错. <script type="text/javascript"> ...

  9. SpringMVC使用POST方法传递数据,却出现Request method 'GET' not supported?

    转自:https://segmentfault.com/q/1010000011245770 问题:没有使用get获取当前页面解决方案:   @RequestMapping(value = " ...

  10. Did not find handler method for springMVC资源文件扫描不到---关于spring的那些坑

    今天将项目的spring版本升级到4.2.5版本后,登录首页发现资源文件全部访问不到,页面彻底挂掉: 查找原因,后来又查找spring的更新文档后,才确认下来原来是mvc-dispatcher-ser ...

随机推荐

  1. selenium 调用键盘按键

    1.想要调用键盘按键操作需要引入keys包: from selenium.webdriver.common.keys import keys 通过send_keys() 调用按键 send_keys( ...

  2. Window window = Window.GetWindow(控件)

    Window window = Window.GetWindow(控件)

  3. jQuery Mobile事件,开发全解+完美注释

    全栈工程师开发手册 (作者:栾鹏) jQuery Mobile事件全解 jQuery Mobile 所有class选项 jQuery Mobile 所有data-*选项 jQuery Mobile事件 ...

  4. 关于KVO导读

    入门篇 KVO是什么? Key-value observing is a mechanism that allows objects to be notified of changes to spec ...

  5. jenkins、ant、selenium、testng搭建自动化测试框架

    如果在你的理解中自动化测试就是在eclipse里面讲webdriver的包引入,然后写一些测试脚本,这就是你所说的自动化测试,其实这个还不能算是真正的自动化测试,你见过每次需要运行的时候还需要打开ec ...

  6. python xml sendEmail

    使用python进行发送邮件,研究的主要是用smtplib这个包,具体代码如下,eg: #!/usr/bin/python #coding=utf-8 import smtplib from emai ...

  7. 张高兴的 Windows 10 IoT 开发笔记:RTC 时钟模块 DS3231

    GitHub:https://github.com/ZhangGaoxing/windows-iot-demo/tree/master/DS3231 注意:不包含闹钟设置

  8. CloneZilla + Parkomat 实现网络备份

    I. 准备 1. 下载 & 烧录 CloneZilla Live 前往 http://clonezilla.org/downloads.php 下载CloneZilla Live,有四个版本, ...

  9. JavaScript函数之实际参数对象(arguments) / callee属性 / caller属性 / 递归调用 / 获取函数名称的方法

    函数的作用域:调用对象 JavaScript中函数的主体是在局部作用域中执行的,该作用域不同于全局作用域.这个新的作用域是通过将调用对象添加到作用域链的头部而创建的(没怎么理解这句话,有理解的亲可以留 ...

  10. DOS和windows的区别?

    2017-09-25  19:18:03 本质:都是微软公司的操作系统,某种从程度上说windows是dos的后续操作系统版本.只是windows相比dos有质的飞跃.dos只支持命令操作,windo ...