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";
}
}
}

Spring Boot—05页面跳转的更多相关文章

  1. Spring Boot 静态页面跳转

    本篇博客仅为自己提个醒:如何跳转页面而不麻烦控制器. 当我们创建 Spring Boot 项目时(勾选了 Thymeleaf 和 Web),目录结构会是如下:        其中图二是我创建了一个 h ...

  2. Spring Boot 静态页面

    spring boot项目只有src目录,没有webapp目录,会将静态访问(html/图片等)映射到其自动配置的静态目录,如下 /static /public /resources /META-IN ...

  3. 16. Spring boot 错误页面

      默认效果:1).浏览器,返回一个默认的错误页面 1.1 请求头 1.2返回结果 2).如果是其他客户端,默认响应一个json数据 2.1请求头 2.2返回结果 { "timestamp& ...

  4. spring boot 启动自动跳到 断点 throw new SilentExitException

    项目 debug 启动,自动跳到 断点 ,而且就算F8 ,项目还是停止启动. 百度了一下,答案都是 Eclipse -> Preferences ->Java ->Debug去掉&q ...

  5. Eclipse使用Debug模式调试Spring Boot项目时跳转到exitCurrentThread的问题

    Spring Boot项目使用了spring-boot-devtools工具且在Eclipse中Debug调试会自动跳转到这个方法: public static void exitCurrentThr ...

  6. spring boot 通过controller跳转到指定 html 页面问题以及请求静态资源问题

    1. 项目结构 2. pom文件配置 重点是红色框内的依赖 3. application配置文件 4. controller 注意使用@Controller注解: @RestController 等价 ...

  7. Spring Boot jsp页面无法跳转问题

    可能的情况如下: 1.未在pom.xml中添加依赖 <!-- jsp 视图支持--> <dependency>    <groupId>org.apache.tom ...

  8. java之spring mvc之页面跳转

    1. 如果返回值为ModelAndView,在处理方法中,返回null时,默认跳转的视图名称为请求名.跳转结果会根据视图解析器来跳转. @RequestMapping("/hello.do& ...

  9. 关于thymeleaf+layout布局的使用方式,spring boot 访问页面(静态页面及jsp页面)

    首先建立相同部分的html,这里我命名为layout.html,放在了`templates/layout'文件夹下,这个路径以后是会用到的,以下是我的layout的代码,比较粗糙. 但是应该会更好的帮 ...

随机推荐

  1. POJ 2363

    #include<iostream> #include<stdio.h> using namespace std; int main() { //freopen("a ...

  2. UiAutomator -- UiObject2 API

    1.点击与长按 void click() Clicks on this object. void click(long duration) Performs a click on this objec ...

  3. Linux CentOS7系统中mysql8安装配置

    mysql是世界上最流行的关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司所有.今天我将记录一下如何在Linux centos7系统上安装和配置MySQL. 目录 环境准 ...

  4. SpringMVC3.2+Spring3.2+Mybatis3.1(SSM~Demo)

    SpringMVC+Spring+Mybatis 框架搭建 整个Demo的视图结构: JAR: 下载地址:http://download.csdn.net/detail/li1669852599/85 ...

  5. windows server 2016安装docker

    最近微软发布了windows server 2016,并原生支持docker,本文通过一系列的步骤,来学习怎么在windows server 2016安装docker. 1.下载 windows se ...

  6. spring自定义注解拦截器的配置

    1.创建注解文件 (文件格式为注解) 这里面什么都不需要写 文件名就是注解名称 如下 是@anno package com.ABC123.anno; import java.lang.annotati ...

  7. 关于 PHP 开放 enable_dl 函数利用 图片Disable_functions

    三篇引文地址: 利用PHP扩展模块突破Disable_functions执行命令 如何编写PHP扩展 php dl函数(详细解释)

  8. rails 5.2 启动警告 warning: previous definition of VERSION was here和bootsnap

    bootsnap依赖问题 You should add gem 'bootsnap' to your gemfile to install it or remove the line require ...

  9. Nginx安装图片模块出错,提示fatal error: curl/curl.h

    获得安装包,从网上直接下载下载地址:https://curl.haxx.se/download.html 然后解压安装后就可以了 # # cd curl- # ./configure # make & ...

  10. 问题记录 | PyLint not recognizing cv2 members

    问题记录 | PyLint not recognizing cv2 members VScode中安装了pylint,总是提示cv2的一些成员函数找不到, 如这样的问题: Module 'cv2' h ...