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的代码,比较粗糙. 但是应该会更好的帮 ...
随机推荐
- template.js插件和ajax一起使用的例子
template.js 一款 JavaScript 模板引擎,简单,好用.提供一套模板语法,用户可以写一个模板区块,每次根据传入的数据,生成对应数据产生的HTML片段,渲染不同的效果. https:/ ...
- JS滑动到页面底部
window.scrollTo(0, document.documentElement.clientHeight); 该 window 对象在DOM有一个 scrollTo 滚动到打开窗口 的任意位置 ...
- h5预订酒店项目|html5酒店模板|h5酒店webapp开发
近几天尝试着使用html5+css3+swiper+jqUI+layerMobile等技术开发了一款仿携程.去哪儿.艺龙webapp酒店预订系统,页面图标统一使用iconfont,仿原生app右侧弹窗 ...
- if嵌套语句 shell脚本实例 测试是否闰年
在 if 语句里面,你可以使用另外一个 if 语句.只要你能逻辑管理 你就可以使用多层嵌套. 以下是一个测试闰年的例子: #!/bin/bash # This script will test if ...
- 解析ASP.NET Mvc开发之查询数据实例 分类: ASP.NET 2014-01-02 01:27 5788人阅读 评论(3) 收藏
目录: 1)从明源动力到创新工场这一路走来 2)解析ASP.NET WebForm和Mvc开发的区别 ----------------------------------------------- ...
- 【es6】class
class是es6引入的最重要特性之一.在没有class之前,我们只能通过原型链来模拟类. 基本用法 如果你用过java这样的纯面向对象语言,那么你会对class的语法非常熟悉. class Peop ...
- Eclipse及IDEA插件开发
https://github.com/eclipse/eclipse.jdt.ui http://www.eclipse.org/jdt/ui/ https://www.cnblogs.com/xin ...
- 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 ...
- Memcached理解笔记4---应对高并发攻击
近半个月过得很痛苦,主要是产品上线后,引来无数机器用户恶意攻击,不停的刷新产品各个服务入口,制造垃圾数据,消耗资源.他们的最好成绩,1秒钟可以并发6次,赶在Database入库前,Cache进行Mis ...
- elasticsearch的join查询
1.概述 官方文档 https://www.elastic.co/guide/en/elasticsearch/reference/current/joining-queries.html 两种类型的 ...