结果跳转方式|学习笔记

简介: 快速学习结果跳转方式

开发者学堂课程【SpringMVC框架入门:结果跳转方式】学习笔记,与课程紧密联系,让用户快速学习知识。

课程地址:https://developer.aliyun.com/learning/course/22


结果跳转方式

跳转结果的方式

1、设置ModelAndView对象

2、通过ServletAPI对象来实现

3.、通过spring mvc来实现转发和重定向没有视图解析器

4、通过spring mvc来实现转发和重定向有视图解析器转发方式

1、设置ModelAndView对象。

根据view的名称,和视图解析器跳转到指定的页面。

页面:视图解析器的前缀+view name+视图解析器的后缀

ModelAndView my new ModelAndView();

//封装要显示到视图中的数据

mv

. addobject("msg", "hello annotation");

//视图名

msetViewName("hello");//web-inf/isp/hello.isp

image.pngimage.pngimage.pngimage.png

2通过ServletAPI对象来实现。

不需要视图解析器的配置

public void hello(httpservletreque reg, httpservletresponse

resp) throws IOException{

resp.getWriter(). println("hello spring mys use

httpservlet api");l

image.png

image.png

image.png

image.png


3.、通过spring mvc来实现转发和重定向没有视图解析器

转发的实现(1)

@RequestMapping("/hello1")

public String hello({

//转发

return "index. isp";

image.png

转发的实现2

@RequestMapping("/hello1")

public String hello({

//转发1

//return "index, isp";

//转发2

System.out. println("转发2");

return "forward: index. isp";

image.pngimage.png

image.png

image.png

重定向

@RequestMapping("/hello1")

public String helloO{

//转发1

//return "index. isp";

//转发2

System.out. printIn("转发2)

/return "forward: index.isp";

/重定向

return "redirect: index.jsp

image.png

4、通过spring mvc来实现转发和重定向有视图解析器

@RequestMapping("/hello2")

public String hello2({

return "hello";

image.png

相关文章
|
4月前
|
开发框架 移动开发 Android开发
uniapp的几种跳转方式
uniapp的几种跳转方式
|
4月前
uniapp的两个跳转方式
uniapp的两个跳转方式
|
5月前
|
小程序 前端开发
小程序扫码成功后带着参数跳转到指定页面
小程序扫码成功后带着参数跳转到指定页面
105 0
|
3月前
|
小程序
微信小程序实现不同按钮跳转同一个页面显示不同内容
微信小程序实现不同按钮跳转同一个页面显示不同内容
62 0
|
2月前
|
小程序 JavaScript 前端开发
【每周一个小技巧】支付宝小程序跳转生活号的几种方式
【每周一个小技巧】支付宝小程序跳转生活号的几种方式
34 1
|
4月前
|
JSON 小程序 API
微信小程序学习笔记(4) -- 页面间的跳转和传值
微信小程序学习笔记(4) -- 页面间的跳转和传值
|
8月前
|
小程序
微信小程序5种路由跳转的区别
微信小程序5种路由跳转的区别
|
4月前
|
小程序
微信小程序如何进行跨页面传参,并在跳转后的页面获取参数
微信小程序如何进行跨页面传参,并在跳转后的页面获取参数
114 0
|
12天前
|
前端开发
【前端学习】—路由跳转的三种方式(十九)
【前端学习】—路由跳转的三种方式(十九)
|
5月前
|
开发框架 移动开发 JavaScript
uniapp跳转方式
uniapp跳转方式
41 0