WebMvcConfigurerAdapter的用法
来源:互联网 发布:免费手机安装窃听软件 编辑:程序博客网 时间:2024/06/07 16:36
以前写Spring MVC的时候,要添加一个新页面访问总是要新增一个Controller或者在已有的一个Controller中新增一个方法,然后再跳转到设置的页面上去。考虑到大部分应用场景中View和后台都会有数据交互,这样的处理也无可厚非,不过我们肯定也有只是想通过一个URL Mapping然后不经过Controller处理直接跳转到页面上的需求!今天在做Spring Security相关配置的时候偶然发现了Spring也为我们提供了一个办法!那就是 WebMvcConfigurerAdapter !废话不多说了,直接看代码:
package com.cloume.agvs.configuration;import org.springframework.context.annotation.Configuration;import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;@Configurationpublic class MVCConfiguration extends WebMvcConfigurerAdapter {@Overridepublic void addViewControllers(ViewControllerRegistry registry){registry.addViewController("/login").setViewName("login");}}那么通过上面的配置,不用添加LoginController或者处理“login”的方法就可以直接通过“http://localhost:8080/projectContext/login”访问到login.html页面了!
1 0
- WebMvcConfigurerAdapter的用法
- WebMvcConfigurerAdapter的用法
- SpringMVC的WebMvcConfigurerAdapter
- WebMvcConfigurerAdapter
- spring mvc的拦截器WebMvcConfigurerAdapter
- spring boot 拦截器之WebMvcConfigurerAdapter
- Spring Boot拦截器(WebMvcConfigurerAdapter)
- java 方式配置spring mvc 继承WebMvcConfigurerAdapter和继承WebMvcConfigurationSupport
- 《Springboot极简教程》继承WebMvcConfigurerAdapter: 一行代码写Controller
- Spring Boot自定义MVC配置——WebMvcConfigurerAdapter
- Spring Boot WebMvcConfigurerAdapter 实现拦截器无配置
- springBoot 使用继承WebMvcConfigurerAdapter 添加多个拦截器和继承HandlerInterceptorAdapter创建拦截器
- ?的用法
- ?的用法
- ---" ~ " 的用法---
- ---" ~ " 的用法---
- ~ 的用法
- 的用法
- 使用ftp传输文件到arm板
- Your password has expired. To log in you must change it using a cl...
- VO(DTO)模式在分层架构设计中是否需要的扯淡
- 企业如何选购适合的视频会议产品
- shell脚本 自定义传入参数选项
- WebMvcConfigurerAdapter的用法
- C++调用webservice
- IOS UIWebView与Javascript之间的交互
- The Bonus Salary! (poj 3762 离散化+最小费用流)
- Android自定义ImageView,方角,圆角头像(可根据自己的需求来设定头像的圆角或者方角的大小)
- git fetch 同步太多不需要的
- Hibernate-简介
- (15/09/14)重新开始
- Java序列化框架性能比较