12.16 视图解析器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
@Controller
public class ViewResolver {
//方法1 相对路径法
@RequestMapping("/Hello")
public String hello(){
return "../../hello";//相对路径的形式访问hello.jsp
}
//方法2
@RequestMapping("/Hello01")
public String hello01(){
return "forward:/hello.jsp";//相对路径的形式访问hello.jsp
}
//方法3 把请求转发到handle01
@RequestMapping("/Hello02")
public String hello02(){
return "forward:/Hello01";
}
//forward:前缀的转发 不会由视图解析器品串

//重定向redirect:+重定向的路径
@RequestMapping("/hello03")
public String hello03(){
return "redirect:/hello.jsp";
}
}
-------------文章已结束~感谢您的阅读-------------
穷且益坚,不堕青云之志。