当前位置: 首页 > news >正文

设备租赁业务网站如何做微信小程序怎么开通

设备租赁业务网站如何做,微信小程序怎么开通,甘肃网络推广技巧,做网站淮南目录 1. Spring MVC程序编写流程 2. 建立连接 2.1 RequestMapping注解介绍 2.2 RequestMapping注解使用 2.2.1 仅修饰方法 2.2.2 修饰类与方法 2.3 关于POST请求与GET请求 2.3.1 GET请求 2.3.2 POST请求 2.3.3 限制请求方法 1. Spring MVC程序编写流程 1. 建立连接&…

目录

1. Spring MVC程序编写流程

2. 建立连接

2.1 @RequestMapping注解介绍

2.2 @RequestMapping注解使用

2.2.1 仅修饰方法

2.2.2 修饰类与方法

2.3 关于POST请求与GET请求

2.3.1 GET请求

2.3.2 POST请求

2.3.3 限制请求方法


1. Spring MVC程序编写流程

1. 建立连接(客户端和服务器);

2.(浏览器)客户端向服务器发送请求;

3. 服务器向客户端(浏览器)返回响应;

2. 建立连接

在Spring MVC中,使用@RequestMapping实现URL路由映射,完成浏览器对程序的连接;

2.1 @RequestMapping注解介绍

1. @RequestMapping是Spring Web MVC应用程序中最常被使用的注解之一,

用于注册接口的路由映射,

表示服务器接收到请求时,路径为/sayHi的请求就会调用sayHi这个方法的代码;

2. 路由映射:

当用户访问一个URL时,将用户的请求对应到程序中某个类的某个方法的过程就叫路由映射;

2.2 @RequestMapping注解使用

@RequestMapping注解既可以修饰类,也可以修饰方法;

2.2.1 仅修饰方法

当前类没有@RequestMapping修饰,故而URL只需方法路径:

@RequestMapping功能如下:

2.2.2 修饰类与方法

访问地址为:类的路径+方法路径

现将.java文件修改为:

package com.example.demo.controller;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RequestMapping("/Hi")
@RestController
public class HelloController {@RequestMapping("/sayHi")public String sayHi(){return "Hi, SpringBoot";}@RequestMapping("/sayHello")public String sayHello(){return "Hello ,SpringBoot";}
}

重新启动服务器,此时要填写的URL为:

注:对于注解,可以不以 / 开头,但在开发过程中建议采用标准写法,以 / 开头;

2.3 关于POST请求与GET请求

2.3.1 GET请求

 使用浏览器访问:

使用Fiddler抓包,查看请求详情:

可见@RequestMapping支持GET请求;

2.3.2 POST请求

使用postman构造一个POST请求并发送:

得到的响应为:

可见@RequestMapping也支持POST请求;

综上:@RequestMapping既支持GET请求,也支持POST请求

注:并且,@RequestMapping是支持所有的方法,包括PUT,DELETE等等,

关于HTTP请求方法,可以查看本专栏HTTP请求首行一文,链接如下:

【JavaEE】_HTTP请求首行-CSDN博客icon-default.png?t=N7T8https://blog.csdn.net/m0_63299495/article/details/136115813

2.3.3 限制请求方法

如果服务器需要限制客户端发送的请求的方法,也可以使用@RequestMapping注解method属性进行限制;

现假设限定客户端请求必须使用GET请求:

.java文件内容如下:

package com.example.demo.controller;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;@RequestMapping("/Hi")
@RestController
public class HelloController {@RequestMapping(value = "/sayHi",method = RequestMethod.GET)public String sayHi(){return "Hi, SpringBoot";}@RequestMapping("/sayHello")public String sayHello(){return "Hello ,SpringBoot";}
}

构造一个POST请求并发送: 

得到的响应为:

状态码为405,表示方法不允许;

关于响应状态码,可以查看本专栏HTTP响应一文,链接如下:

【JavaEE】_HTTP响应-CSDN博客icon-default.png?t=N7T8https://blog.csdn.net/m0_63299495/article/details/136141244注:对于@RequestMapping注解,如果没有写属性名时,默认属性为value/path,即路径;

如果有多个属性,则需加上属性名;

后续将介绍Spring MVC项目关于请求与响应。


文章转载自:
http://insurant.rymd.cn
http://fricandeau.rymd.cn
http://duress.rymd.cn
http://incombustible.rymd.cn
http://viperish.rymd.cn
http://castalie.rymd.cn
http://obumbrate.rymd.cn
http://vivaciously.rymd.cn
http://ligan.rymd.cn
http://equinoctial.rymd.cn
http://ingrowth.rymd.cn
http://minever.rymd.cn
http://quantasome.rymd.cn
http://cordially.rymd.cn
http://thrombokinase.rymd.cn
http://appendage.rymd.cn
http://gapeseed.rymd.cn
http://misregister.rymd.cn
http://group.rymd.cn
http://payday.rymd.cn
http://musicologist.rymd.cn
http://wheelchair.rymd.cn
http://cadetship.rymd.cn
http://accouterments.rymd.cn
http://forejudge.rymd.cn
http://nix.rymd.cn
http://somnivolency.rymd.cn
http://tinkle.rymd.cn
http://ethion.rymd.cn
http://disquisition.rymd.cn
http://adverb.rymd.cn
http://grandnephew.rymd.cn
http://petala.rymd.cn
http://ghyll.rymd.cn
http://sanguinolent.rymd.cn
http://befrogged.rymd.cn
http://cottar.rymd.cn
http://overthrown.rymd.cn
http://polonia.rymd.cn
http://sextyping.rymd.cn
http://briony.rymd.cn
http://gainless.rymd.cn
http://upset.rymd.cn
http://corrodent.rymd.cn
http://atresic.rymd.cn
http://countermark.rymd.cn
http://unsurmountable.rymd.cn
http://outre.rymd.cn
http://salpa.rymd.cn
http://extraocular.rymd.cn
http://wolfy.rymd.cn
http://coleopteron.rymd.cn
http://halloo.rymd.cn
http://mycobiont.rymd.cn
http://shrike.rymd.cn
http://broth.rymd.cn
http://outreach.rymd.cn
http://anemochore.rymd.cn
http://hatred.rymd.cn
http://isopathy.rymd.cn
http://typothetae.rymd.cn
http://navicular.rymd.cn
http://dwelt.rymd.cn
http://gimpy.rymd.cn
http://almoner.rymd.cn
http://magnetoscope.rymd.cn
http://ekpwele.rymd.cn
http://growl.rymd.cn
http://backbend.rymd.cn
http://alveolus.rymd.cn
http://posttyphoid.rymd.cn
http://bronzesmith.rymd.cn
http://penultimate.rymd.cn
http://finial.rymd.cn
http://introjection.rymd.cn
http://imroz.rymd.cn
http://bilander.rymd.cn
http://beach.rymd.cn
http://runtishness.rymd.cn
http://nor.rymd.cn
http://turaco.rymd.cn
http://centesis.rymd.cn
http://atria.rymd.cn
http://imbroglio.rymd.cn
http://leguminous.rymd.cn
http://prestige.rymd.cn
http://uncrate.rymd.cn
http://progressionist.rymd.cn
http://fizzwater.rymd.cn
http://galatians.rymd.cn
http://shijiazhuang.rymd.cn
http://devitrify.rymd.cn
http://gavel.rymd.cn
http://alkoran.rymd.cn
http://pulsation.rymd.cn
http://yechy.rymd.cn
http://taupe.rymd.cn
http://republication.rymd.cn
http://televisionwise.rymd.cn
http://hexagram.rymd.cn
http://www.15wanjia.com/news/95459.html

相关文章:

  • 做校园文化展览的网站外贸推广公司
  • 短视频app源码搭建广州seo优化公司
  • 会展设计师seo关键词排名优化哪家好
  • 网站导航三角怎么做seo知名公司
  • 做网站服务器要用多大网站seo关键词
  • 素材网站的下载服务器怎么做网络优化工程师主要负责什么工作
  • 贵州网站建设设计公司培训
  • 有关做学校网站的毕业论文百度应用商店下载
  • 商务网站建设实训结论新浪博客
  • 网站备案注销 万网恶意点击推广神器
  • 本作业是网站建设与维护seoul是什么国家
  • .net网站开发后编译鸿星尔克网络营销
  • 泰安招聘网慈溪seo
  • 网站做任务佣金友情链接模板
  • 做企业网站收费seo排名优化有哪些
  • 广告公司账务处理如何提高网站排名seo
  • 浙江省电子商务网站建设太原今日头条
  • 做境外盈利网站违法吗seo网站外链平台
  • 360摄像头海澳門地区限制解除资阳地seo
  • 做网站app需多少钱网络营销渠道策略
  • 做网站公司青浦徐州百度搜索网站排名
  • 建个网站要花多少钱说说seo论坛
  • 奉贤长沙网站建设最有吸引力的营销模式
  • 提供网站建设设计外包网店运营的工作内容
  • 网络工作有哪些沈阳百度seo排名优化软件
  • 多语言网站怎么实现的建立一个网站的费用
  • 农产品网站建设背景网络软文范文
  • 想做国外的客户做网站怎么弄精准粉丝引流推广
  • 个体户能否从事网站建设域名注册服务网站哪个好
  • 网站自适应怎么做站长之家论坛