惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
博客园_首页
H
Help Net Security
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
B
Blog
I
InfoQ
SecWiki News
SecWiki News
T
Tailwind CSS Blog
Spread Privacy
Spread Privacy
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
P
Palo Alto Networks Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
Kaspersky official blog
M
MIT News - Artificial intelligence
S
Schneier on Security
T
Threat Research - Cisco Blogs
F
Fortinet All Blogs
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
The Cloudflare Blog
Recent Announcements
Recent Announcements
Security Latest
Security Latest
G
GRAHAM CLULEY
IT之家
IT之家
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
腾讯CDC
Google DeepMind News
Google DeepMind News
V
V2EX
S
Securelist
TaoSecurity Blog
TaoSecurity Blog
B
Blog RSS Feed
S
SegmentFault 最新的问题
博客园 - 叶小钗
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Project Zero
Project Zero
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
F
Full Disclosure

博客园 - 小猫钓鱼吃鱼

把Claude Code玩明白:VS Code零成本接入DeepSeek大模型 硅基流动-免费代金券 告别从零造轮子!我的 Electron+Vue3 脚手架,让你 10 秒启动桌面应用开发 Electron劝退指南?不,这是我的‘真香’致富经 一个面向产品化的 Electron + Vue 3 桌面应用脚手架 动态代理 自己实现HashMap 自己实现Linkedlist,实现其常用的增、删、查的方法 自己实现Arraylsit,实现其常用的几种增、删、该、查的方法 前后端分离 微服务项目 通用后台管理系统 easypoi一行代码搞定excel导入导出 如何跳出页面的Frame框架 如何从GitHub上下载部分自己需要的文件 Mysql Explain 详解 解决 spring boot Failed to decode downloaded font Java中List集合的三种遍历方式(全网最详) idea中搭建ssm框架,详细步骤 微信公众号分享知识 idea创建maven项目速度慢?别急,这有三种方案 ceph是什么 redis 注册开机自启动服务(注意:要到你安装redis的根目录下执行下面的cmd命令) 怎么让mac和win/pc互传文件共享文件传输文件 Starting MySQL... ERROR! The server quit without updating PID file 问题解决
SpringBoot设置首页(默认页)跳转功能的实现方案
小猫钓鱼吃鱼 · 2020-03-18 · via 博客园 - 小猫钓鱼吃鱼

最近springboot开发需要设置个默认页面,要直接跳转到登录页面。

方案1:controller里添加一个"/"的映射路径

@RequestMapping("/")
public String index(Model model, HttpServletResponse response) {
  model.addAttribute("name", "simonsfan");
  return "/index";
}

方案二:设置默认的View跳转页面

@Configuration
public class DefaultView extends WebMvcConfigurerAdapter {
  @Override
  public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/").setViewName("index");
    registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
    super.addViewControllers(registry);
  }
}
@Configuration
public class DefaultView extends WebMvcConfigurerAdapter{
  @Override
  public void addViewControllers(ViewControllerRegistry registry) {
    super.addViewControllers(registry);
    //主页
    registry.addViewController("/").setViewName("forward:/index");
  } 
}