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. iOS 关于布局问题的一些认识

    ///更新约束和布局 更新约束布局相关的API - (void)updateConstraintsIfNeeded  调用此方法,如果有标记为需要重新布局的约束,则立即进行重新布局,内部会调用upda ...

  2. Swift的Guard语句

    与if语句相同的是,guard也是基于一个表达式的布尔值去判断一段代码是否该被执行.与if语句不同的是,guard只有在条件不满足的时候才会执行这段代码.你可以把guard近似的看做是Assert,但 ...

  3. Swift 4.0 废弃的柯里化

    // 柯里化 // http://www.jianshu.com/p/6eaacadafa1a                               Swift 2.0 柯里化方法 (废弃) / ...

  4. C#获取文件版本、文件大小等信息

    使用以下C#程序代码可以非常方便地获取Windows系统中任意一个文件(尤其是可执行文件)的文件版本.文件大小.版权.产品名称等信息.所获取到的信息类似于在Windows操作系统中右键点击该文件,然后 ...

  5. spring中的context:include-filter和context:exclude-filter的区别

    在Spring 的配置文件中有: <context:component-scan base-package="njupt.dao,njupt.service"> < ...

  6. Eclipse无法编译 build无效 没有class文件

    问题原因: 我遇到这个问题的原因是: maven 插件引起的,maven clean或maven build后,经常无法自动编译class(虽然project自动编译了,但是只有包文件夹名,而没有cl ...

  7. linux传输文件命令: rz 和 sz

    参考: https://www.cnblogs.com/xiluhua/p/6218563.html https://blog.csdn.net/u014242496/article/details/ ...

  8. Angularjs集成第三方js插件之Uploadify

    有时候需要用一些第三方插件,比如datepicker,slider,或者tree等.以前的做法是直接通过jquery取得某个元素,然后调用某个方法即可.但在angularjs中,不能直接这么写,必须写 ...

  9. Spring Security构建Rest服务-1204-Spring Security OAuth开发APP认证框架之Token处理

    token处理之一基本参数配置 处理token时间.存储策略,客户端配置等 以前的都是spring security oauth默认的token生成策略,token默认在org.springframe ...

  10. ambari 2.6.2 安装 hdp 2.6.5.0 遇到的问题

    1.hive-client 无法安装 一直报错(symlink target  already exists and it is not a symlink.),hive-client 已经存在且不是 ...