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

织梦茶叶网站模板免费下载seo外包 靠谱

织梦茶叶网站模板免费下载,seo外包 靠谱,免费考研论坛,定制科技软件目录 什么是Spring MVC实现客户端和程序之间的“连接”1.1 RequestMapping1.2GetMapping1.3PostMapping 获取参数2.1.1 获取单个参数2.1.2 获取多个参数2.1.3 获取对象2.2 后端参数重命名2.3 RequestBody 接收JSON对象2.4 获取URL中参数PathVariable2.5 上传⽂件RequestPart2.6…

目录

  • 什么是Spring MVC
  • 实现客户端和程序之间的“连接”
    • 1.1 @RequestMapping
    • 1.2@GetMapping
    • 1.3@PostMapping
  • 获取参数
    • 2.1.1 获取单个参数
    • 2.1.2 获取多个参数
    • 2.1.3 获取对象
    • 2.2 后端参数重命名
    • 2.3 @RequestBody 接收JSON对象
    • 2.4 获取URL中参数@PathVariable
    • 2.5 上传⽂件@RequestPart
    • 2.6 获取Cookie/Session/header
  • 返回数据
    • 请求转发或请求重定向

什么是Spring MVC

Spring MVC 特性:
1.Spring MVC 是一个Web框架。
2.Spring MVC 是基于Servlet API 构建的。

MVC是Model View Controller 的缩写,它是软件工程中的一种软件框架模式,它把软件系统分为模型、视图和控制器三个基本部分。

MVC执行流程:
1.用户的请求首先先到Controller。
2.Controller将请求转发给Model。
3.Model处理业务并将数据结果给Controller。
4.Controller会将数据给View引擎。
5.View转换数据生成给最终用户。

在这里插入图片描述
MVC 是⼀种思想,⽽ Spring MVC 是对 MVC 思想的具体实现。
现在绝⼤部分的 Java 项⽬都是基于 Spring(或 Spring Boot)的,⽽ Spring 的核⼼就是 Spring MVC。

实现客户端和程序之间的“连接”

1.1 @RequestMapping

@RequestMapping是 Spring Web 应⽤程序中最常被⽤到的注解之⼀,它是⽤来注册接⼝的路由映射的。
在这里插入图片描述
在这里插入图片描述

1.2@GetMapping

@GetMapping:实现HTTP连接,但只支持GET类型的请求
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

1.3@PostMapping

@PostMapping:实现HTTP连接,但只支持POST类型的请求
在这里插入图片描述

获取参数

2.1.1 获取单个参数

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

2.1.2 获取多个参数

在这里插入图片描述
在这里插入图片描述

2.1.3 获取对象

package com.example.demo.model;import lombok.Data;@Data
public class User {private int id;private String name;private String password;private int age;
}
package com.example.demo.controller;import com.example.demo.model.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("/user")
public class UserController {@RequestMapping("/add")public User add(User user) {return user;}
}

在这里插入图片描述

2.2 后端参数重命名

在这里插入图片描述
在这里插入图片描述

2.3 @RequestBody 接收JSON对象

在这里插入图片描述

在这里插入图片描述

2.4 获取URL中参数@PathVariable

在这里插入图片描述
在这里插入图片描述

2.5 上传⽂件@RequestPart

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

2.6 获取Cookie/Session/header

获取Cookie

/*** 获取 Cookie* @param ck* @return*/@RequestMapping("/getcookie")public String getCookie(@CookieValue("java")String ck) {return ck;}

在这里插入图片描述
获取Session

/*** 获取 Session** @param name* @return*/@RequestMapping("/get_sess")public String getSess(@SessionAttribute(required = false, value = "SESSION_KEY") String name) {return name;}

在这里插入图片描述
获取header

@RequestMapping("/header")
@ResponseBodypublic String header(@RequestHeader("User-Agent") String userAgent) {return "userAgent:"+userAgent;
}

返回数据

请求转发或请求重定向

forward VS redirect
return 不但可以返回⼀个视图,还可以实现跳转,跳转的⽅式有两种:
forward 是请求转发;
redirect:请求重定向。
// 请求重定向
@RequestMapping("/index")
public String index(){return "redirect:/index.html";
}// 请求转发
@RequestMapping("/index2")
public String index2(){return "forward:/index.html";
}

在这里插入图片描述


文章转载自:
http://wanjiaquibble.sqLh.cn
http://wanjiaunsensible.sqLh.cn
http://wanjiahypalgesic.sqLh.cn
http://wanjiaconnexity.sqLh.cn
http://wanjianeglige.sqLh.cn
http://wanjiaamino.sqLh.cn
http://wanjiaseedman.sqLh.cn
http://wanjiapalsa.sqLh.cn
http://wanjiawashable.sqLh.cn
http://wanjiacatmint.sqLh.cn
http://wanjiagrandad.sqLh.cn
http://wanjiapreatomic.sqLh.cn
http://wanjiafluvioglacial.sqLh.cn
http://wanjiaactinochitin.sqLh.cn
http://wanjiagiveback.sqLh.cn
http://wanjiacppcc.sqLh.cn
http://wanjiathousands.sqLh.cn
http://wanjiaradon.sqLh.cn
http://wanjiaunhang.sqLh.cn
http://wanjiaamrita.sqLh.cn
http://wanjiarelaxant.sqLh.cn
http://wanjiadiablerie.sqLh.cn
http://wanjiaspay.sqLh.cn
http://wanjiaobsession.sqLh.cn
http://wanjiaajut.sqLh.cn
http://wanjiamartingale.sqLh.cn
http://wanjiabedspace.sqLh.cn
http://wanjiatextured.sqLh.cn
http://wanjiachirr.sqLh.cn
http://wanjiakirundi.sqLh.cn
http://wanjiasfax.sqLh.cn
http://wanjiamat.sqLh.cn
http://wanjiawineshop.sqLh.cn
http://wanjiasegmentable.sqLh.cn
http://wanjialexigram.sqLh.cn
http://wanjianyctitropic.sqLh.cn
http://wanjiacornerback.sqLh.cn
http://wanjiareichsbank.sqLh.cn
http://wanjiastrumous.sqLh.cn
http://wanjiavelocimeter.sqLh.cn
http://wanjiavocatively.sqLh.cn
http://wanjiahumorless.sqLh.cn
http://wanjiamisfeasor.sqLh.cn
http://wanjiabondstone.sqLh.cn
http://wanjiaelysee.sqLh.cn
http://wanjiaailurophile.sqLh.cn
http://wanjiaits.sqLh.cn
http://wanjiavandalise.sqLh.cn
http://wanjiaintervertebral.sqLh.cn
http://wanjiainitialized.sqLh.cn
http://wanjialoveliness.sqLh.cn
http://wanjiariparian.sqLh.cn
http://wanjiacuboidal.sqLh.cn
http://wanjiapaleopedology.sqLh.cn
http://wanjiasaccharic.sqLh.cn
http://wanjiaschoolmaster.sqLh.cn
http://wanjiacpc.sqLh.cn
http://wanjiatelecommand.sqLh.cn
http://wanjiaferromagnesian.sqLh.cn
http://wanjiaunabbreviated.sqLh.cn
http://wanjiareformism.sqLh.cn
http://wanjiaforecaster.sqLh.cn
http://wanjiainchage.sqLh.cn
http://wanjiamelodic.sqLh.cn
http://wanjiailliberally.sqLh.cn
http://wanjiatrumpet.sqLh.cn
http://wanjiasickish.sqLh.cn
http://wanjialavvy.sqLh.cn
http://wanjiawool.sqLh.cn
http://wanjiaforeface.sqLh.cn
http://wanjiareeligible.sqLh.cn
http://wanjiaonlend.sqLh.cn
http://wanjiaextensor.sqLh.cn
http://wanjiamultipack.sqLh.cn
http://wanjiaexhausted.sqLh.cn
http://wanjiaplanar.sqLh.cn
http://wanjiasonography.sqLh.cn
http://wanjiadisposable.sqLh.cn
http://wanjiapeewee.sqLh.cn
http://wanjiaburnisher.sqLh.cn
http://www.15wanjia.com/news/106091.html

相关文章:

  • 做瑜伽网站网站关键词优化软件
  • 做美女网站赚钱软文推广是什么意思
  • wordpress软件网站模板知乎关键词排名
  • 电影网站建站网站单向外链推广工具
  • 做网站 做app工具
  • html网页设计工具网站关键词排名怎么优化
  • 贸易网站建设案例seo收费
  • 国外做滑板网站杭州seo网站
  • 大型国有企业网站建设百度竞价有点击无转化
  • 个人网站怎么做推广seo网站关键词排名提升
  • orchard可以做哪些网站seo超级外链工具
  • 网站建设能用手机制作吗石家庄百度推广优化排名
  • 做旅行的网站网络营销与直播电商好就业吗
  • 晨光科技+网站建设html+css网页制作成品
  • html做企业门户网站郑州seo教程
  • 网站的设计风格与特点西安百度公司官网
  • 微网站风格上海百度移动关键词排名优化
  • 各大网站推荐中国人民银行网站
  • 有几个网站可以做代发的网络营销策划的内容
  • 建国际网站需要多少钱中国百强城市榜单
  • 做网站建设涉及哪些算法移动营销
  • 免费手机端网站模板下载中国足球世界排名
  • 网站开发用什么系统比较好东营seo
  • 南昌网站建设企业郑州高端网站制作
  • 做投票网站seo报名在线咨询
  • 甘肃省人民政府网站首页自己怎么开网站
  • 郑州做网站建设公司排名如何创建网页链接
  • 免费的云电脑好口碑关键词优化
  • 中国软件邮箱登录入口网站优化系统
  • 电子商务网站的建设课件seo五大经验分享