zoukankan      html  css  js  c++  java
  • Spring Boot—05页面跳转


    package com.smartmap.sample.ch1.controller.view;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.util.StringUtils;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestParam;
    
    @Controller
    @RequestMapping("/system")
    public class MainViewController {
    
        @RequestMapping("")
        public String index(@RequestParam(required = false, name = "sessionId") String sessionId, Model model) {
            if (sessionId == null || sessionId.equals("")) {
                return "redirect:/system/login.html";
                // return "forward:/system/login.html";
            } else {
                String osName = System.getProperty("os.name");
                model.addAttribute("name", "hello world");
                model.addAttribute("host", osName);
                return "index";
            }
        }
    
        @RequestMapping("/login.html")
        public String login(@RequestParam(required = false, name = "username") String username,
                @RequestParam(required = false, name = "password") String password, Model model) {
    
            if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
                return "login.html";
            } else {
                return "redirect:/system?sessionId=12345";
            }
        }
    }
  • 相关阅读:
    STL容器内数据删除
    grep 同时满足多个关键字和满足任意关键字
    程序运行栈空间不足程序崩溃问题
    VS2010中设置程序以管理员身份运行
    python 包详解
    select 详解
    Hdu 1166
    CF1204C
    CF1204B
    CF1204A
  • 原文地址:https://www.cnblogs.com/gispathfinder/p/8920947.html
Copyright © 2011-2022 走看看