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";
}
}
}
Spring Boot—05页面跳转的更多相关文章
- Spring Boot 静态页面跳转
本篇博客仅为自己提个醒:如何跳转页面而不麻烦控制器. 当我们创建 Spring Boot 项目时(勾选了 Thymeleaf 和 Web),目录结构会是如下: 其中图二是我创建了一个 h ...
- Spring Boot 静态页面
spring boot项目只有src目录,没有webapp目录,会将静态访问(html/图片等)映射到其自动配置的静态目录,如下 /static /public /resources /META-IN ...
- 16. Spring boot 错误页面
默认效果:1).浏览器,返回一个默认的错误页面 1.1 请求头 1.2返回结果 2).如果是其他客户端,默认响应一个json数据 2.1请求头 2.2返回结果 { "timestamp& ...
- spring boot 启动自动跳到 断点 throw new SilentExitException
项目 debug 启动,自动跳到 断点 ,而且就算F8 ,项目还是停止启动. 百度了一下,答案都是 Eclipse -> Preferences ->Java ->Debug去掉&q ...
- Eclipse使用Debug模式调试Spring Boot项目时跳转到exitCurrentThread的问题
Spring Boot项目使用了spring-boot-devtools工具且在Eclipse中Debug调试会自动跳转到这个方法: public static void exitCurrentThr ...
- spring boot 通过controller跳转到指定 html 页面问题以及请求静态资源问题
1. 项目结构 2. pom文件配置 重点是红色框内的依赖 3. application配置文件 4. controller 注意使用@Controller注解: @RestController 等价 ...
- Spring Boot jsp页面无法跳转问题
可能的情况如下: 1.未在pom.xml中添加依赖 <!-- jsp 视图支持--> <dependency> <groupId>org.apache.tom ...
- java之spring mvc之页面跳转
1. 如果返回值为ModelAndView,在处理方法中,返回null时,默认跳转的视图名称为请求名.跳转结果会根据视图解析器来跳转. @RequestMapping("/hello.do& ...
- 关于thymeleaf+layout布局的使用方式,spring boot 访问页面(静态页面及jsp页面)
首先建立相同部分的html,这里我命名为layout.html,放在了`templates/layout'文件夹下,这个路径以后是会用到的,以下是我的layout的代码,比较粗糙. 但是应该会更好的帮 ...
随机推荐
- Go语言学习笔记(2)——变量、常量
1. 变量(变量由字母.数字和下划线组成,且不能以数字开头!) 1.1 第一种 var name type // 未赋值时使用默认值 name = value 1.2 第二种: 根据所赋的值 ...
- POJ 2247
#include<iostream> #include<algorithm> #include<vector> #include<string> #in ...
- docker registry push错误“server gave HTTP response to HTTPS client”
系统环境:centos7 docker版本: 1.12.3(注意版本,可能存在不同版本设置不同的情况) docker registry版本:2.4.1 问题: 成功安装docker registry, ...
- java8新特性-入门摘要
本文是针对java8做的入门摘要笔录,详细分析可参见如下原文. 原文地址 http://www.javacodegeeks.com/2013/02/java-8-from-permgen-to-met ...
- 【数组】Container With Most Water
题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, a ...
- Maven启动代理服务器
0.什么叫代理服务器? 代理服务器英文全称是(Proxy Server),其功能就是代理网络用户去取得网络信息.形象的说:它是网络信息的中转站. 代理服务器就好象一个大的Cache,这样就能显著提高浏 ...
- Vue图片懒加载之lazyload插件使用
当内容没有加载完的时候,用户体验不是很好,这时候,可以使用lazyload这个插件,提升用户体验,使用方法特别简单易用 一. vue lazyload插件: 插件地址:https://github.c ...
- ES6-let、const和块级作用域
1.介绍 总的来说,ES6是在ES2015的基础上改变了一些书写方式,开放了更多API,这样做的目的最终还是为了贴合实际开发的需要.如果说一门编程语言的诞生是天才的构思和实现,那它的发展无疑就是不断填 ...
- AndroidStudio报错Software caused connection abort: recv failed
Software caused connection abort: recv failed 这个问题网上有一种说法 已知会导致这种异常的一个场景如下: 客户端和服务端建立tcp的短连接,每次客户端发送 ...
- R语言中常用包(二)
数据导入 以下R包主要用于数据导入和保存数据 feather:一种快速,轻量级的文件格式.在R和python上都可使用readr:实现表格数据的快速导入.中文介绍可参考这里readxl:读取Micro ...