016 SpringMVC中重定向

1.介绍

  

2.index

 1 <%@ page language="java" contentType="text/html; charset=utf-8"
 2     pageEncoding="utf-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 7 <title>Insert title here</title>
 8 </head>
 9 <body>
10     <a href="RedirectTest">Test Redirect</a>    
11     <br><br>
12 
13     <a href="BeanNameTest">Test BeanNameTest</a>    
14     <br><br>
15 </body>
16 </html>

3.concroller

 1 package com.spring.it;
 2 
 3 import org.springframework.stereotype.Controller;
 4 import org.springframework.web.bind.annotation.RequestMapping;
 5 
 6 @Controller
 7 public class RedirectTest {
 8     @RequestMapping("/RedirectTest")
 9     public String hello() {
10         System.out.println("ha ha");
11         return "redirect:/index2.jsp";
12     }
13 }

4.效果

  

原文地址:https://www.cnblogs.com/juncaoit/p/8490838.html