springboot 首页实现,和页面国际化

创建springboot的web项目

可以创建一个config类,对应目录有对应的首页文件

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
    //拓展引用,重写视图控制器方法
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        WebMvcConfigurer.super.addViewControllers(registry);
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/login.html").setViewName("login");
        registry.addViewController("/reset-password").setViewName("reset-password");
        registry.addViewController("/reset-password.html").setViewName("reset-password");
    }
}

页面国际化

  1. 添加插件

  2. 消息路径编写

  3. 页面添加请求参数

  4. 编写对应元素

  5. 接收参数请求,编写请求解析器

  6. config添加bean

posted @   小幼虫虫  阅读(30)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示