SpringMVC---Method
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的更多相关文章
- SpringMVC method属性与http请求方法一致
在springMVC中,@requestMapping注解有method属性,在没有指定method的值时,默认映射所有http请求方法,如果仅想接收一种请求方法,需用method=RequestMe ...
- SpringMVC框架出现 405 request method post not supported 的解决方法
在SpringMVC框架中当使用post请求服务,然后请求成功转到一个静态文件,如html,htm等网页时.页面出现405 request method post not supported错误,只要 ...
- springmvc访问静态资源出现Request method 'GET' not supported
答案最后.:D 默认的访问的URL都会被DispatcherServlet所拦截. 这里说一下如何配置springmvc访问静态文件. <mvc:default-servlet-handler/ ...
- springMVC出现HTTP Status 405 - Request method 'GET' not supported错误的解决方法
今天在写一个简单的springMVC的表单请求处理时,出现了这个问题.我的form表单用的是post方法提交,并没有使用get方法,出现这个问题时,笔者可谓是一脸懵逼. 这是form表单: 这是对po ...
- SpringMVC“Ambiguous mapping found. Cannot map 'XXXController' bean method”解决方法
[转 :http://www.fanfanyu.cn/news/staticpagefile/2351.html] 最近在开发项目的过程中SpringMVC抛了个"Ambiguous map ...
- Springmvc的handler method参数绑定常用的注解
转自:http://blog.longjiazuo.com/archives/1149 1. 简介: handler method参数绑定常用的注解,我们根据他们处理的Request的不同内容部分 ...
- SpringMVC项目中获取所有URL到Controller Method的映射
Spring是一个很好很强大的开源框架,它就像是一个容器,为我们提供了各种Bean组件和服务.对于MVC这部分而言,它里面实现了从Url请求映射控制器方法的逻辑处理,在我们平时的开发工作中并不需要太多 ...
- 使用SpringMVC时报错HTTP Status 405 - Request method 'GET' not supported
GET方法不支持.我出错的原因在于,在JSP中我希望超链接a以post方式提交,但是这里写js代码时出错. <script type="text/javascript"> ...
- SpringMVC使用POST方法传递数据,却出现Request method 'GET' not supported?
转自:https://segmentfault.com/q/1010000011245770 问题:没有使用get获取当前页面解决方案: @RequestMapping(value = " ...
- Did not find handler method for springMVC资源文件扫描不到---关于spring的那些坑
今天将项目的spring版本升级到4.2.5版本后,登录首页发现资源文件全部访问不到,页面彻底挂掉: 查找原因,后来又查找spring的更新文档后,才确认下来原来是mvc-dispatcher-ser ...
随机推荐
- JavaScript设计模式--简单工厂模式
一,介绍 工厂模式创建对象(视为工厂里的产品)时无需指定创建对象的具体类. 工厂模式定义一个用于创建对象的接口,这个接口由子类决定实例化哪一个类.该模式使一个类的实例化延迟到了子类.而子类可以重写接口 ...
- 压缩感知“Hello World”代码初步学习
压缩感知代码初学 实现:1-D信号压缩传感的实现 算法:正交匹配追踪法OMP(Orthogonal Matching Pursuit) >几个初学问题 1. 原始信号f是什么?我采集的是 ...
- 在Git上如何强推代码规范
引言 最近参加了“前端规范制定topic”小组,小组成员一起制定了html.css.js.es6.vue和react等规范,但规范制定好了怎么进行推广去强制执行呢,已知我们的项目都是用git做管理的, ...
- GoldenGate 复制进程报错"OGG-01296 Error mapping",丢弃文件报错“Mapping problem with delete record (target format)”,且实际条目存在
故障描述: (1).复制进程 Abended,通过view report语句查看可发现类似如下的报错: 2017-10-23 15:01:43 ERROR OGG-01296 Error mappin ...
- Zookeeper 笔记-watch
ZooKeeper对Watch提供了什么保障 对于watch,ZooKeeper提供了这些保障: Watch与其他事件.其他watch以及异步回复都是有序的. ZooKeeper客户端库保证所有事件都 ...
- 微信小程序---wx.request(OBJECT)
详情 :https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-request.html#wxrequestobject 1: 首先要配置你的域名 ...
- web开发|如何选择合适的webui框架
在市场中很多人分不清框架和库的区别,部分只知道框架模糊的概念.所以在选择webUI框架的时候就会仁者见仁智者见智,会存在各抒己见也是很正常的,这里整体都叫框架吧,在市场中不断的淘汰与创新,主要以Vue ...
- LeetCode 104. Maximum Depth of Binary Tree (二叉树的最大深度)
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- Install a Redmine on Ubuntu system
# How to install a Redmine on Ubuntu system Ref to: https://www.linode.com/docs/applications/project ...
- js解析器的执行原理
首先看一段代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> < ...