前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >转发的两种方式与重定向

转发的两种方式与重定向

作者头像
发布2020-10-23 10:46:17
3430
发布2020-10-23 10:46:17
举报
文章被收录于专栏:后端JavaEE

controller代码

在这里插入图片描述
在这里插入图片描述
代码语言:javascript
复制
package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * zt
 * 2020/10/9
 * 20:44
 */
@Controller
public class MyController {
    /*@RequestMapping("/addUser")
    public String addUser(@RequestParam("name") String username, String password, String email,Integer age){
        System.out.println("username = " + username + ", password = " + password + ", email = " + email + ", age = " + age);
        return "hello2";
    }

    @RequestMapping("/addUsers")
    public String addUsers(User user){
        System.out.println("user = " + user);
        return "hello2";
    }*/

    @RequestMapping("/forward")
    public String forward(){
        System.out.println("这是转发");
//        return "hello2";
        return "forward:hello2.jsp";

    }
    @RequestMapping("/redirect")
    public String redirect(){
        System.out.println("这是重定向");
        return "redirect:hello2.jsp";
    }

}

jsp代码

代码语言:javascript
复制
<%--
  Created by IntelliJ IDEA.
  User: 49841
  Date: 2020/10/9
  Time: 20:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>hello</title>
</head>
<body>
        <%--<form method="post" action="addUsers">
            username:<input type="text" name="username" ><br>
            password:<input type="text" name="password"><br>
            email:<input type="text" name="email"><br>
            age:<input type="text" name="age"><br>
            birthday:<input type="text" name="birthday"><br>
            <input type="submit" value="提交">
        </form>--%>
    <a href="forward">转发</a>
    <a href="redirect">重定向</a>
</body>
</html>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/10/10 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • controller代码
  • jsp代码
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档