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. vue + ajax + php 接口的使用小接

    vue + ajax + php 接口的使用小接 前端代码: (获取用户信息,并渲染页面) userinfor.html <!DOCTYPE html> <html lang=&qu ...

  2. django celery的分布式异步之路(二) 高并发

    当你跑通了前面一个demo,博客地址:http://www.cnblogs.com/kangoroo/p/7299920.html,那么你的分布式异步之旅已经起步了. 性能和稳定性是web服务的核心评 ...

  3. mySQL、mariaDB、noSQL、SQL server、redis之间是什么关系?

    1.首先,从数据库类型上分类,mySQL.mariaDB.SQL server这3种属于关系型数据库. noSQL属于非关系型数据库,被视为数据库革命者. redis成为内存缓存数据库,而前面的两种类 ...

  4. Android基础知识笔记01—框架结构与四大组件

    -----------Andriod 01--------------->>> Andriod系统架构    linux内核与驱动层. 系统运行库层. 应用框架层. 应用层 内核驱动 ...

  5. ThreadPoolExecutor系列<三、ThreadPoolExecutor 源码解析>

    本文系作者原创,转载请注明出处:http://www.cnblogs.com/further-further-further/p/7681826.html 在源码解析前,需要先理清线程池控制的运行状态 ...

  6. javascript 之基本包装类型--04

    基本包装类型 基本包装类型是特殊的引用类型.每当读取一个基本类型值的时候,后台就会创建一个对应的基本包装类型的对象,从而可以调用属性.方法来进行后续操作. ECMAScript还提供了三种基本包装类型 ...

  7. DOS和windows的区别?

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

  8. Python 的装饰器

    Python 在语言级别提供了装饰器模式的实现,代码中Python内置的 functools.wraps 会完成包括函数名属性处理替换 #!/usr/bin/env python3 #--coding ...

  9. python学习笔记(一)之入门

    1.python的安装 官网下载.exe文件直接安装即可,在安装过程中选择加入环境变量,就不用在安装后再去增添环境变量了. 本文选择的是python3.6版本,没有选择2.7版本. 2.启动pytho ...

  10. LeetCode 169. Majority Element (众数)

    Given an array of size n, find the majority element. The majority element is the element that appear ...