zoukankan      html  css  js  c++  java
  • 使用addviewController()实现无业务逻辑跳转

    需要实现WebMvcConfigurer类,重写addViewControllers方法。

    添加@Configuration,等价于xml配置。

    package dbzx.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 WebConfig implements WebMvcConfigurer{
    
        @Override
        public void addViewControllers(ViewControllerRegistry registry) {
            registry.addViewController("test").setViewName("emp/test");
            
        }
        
    }

    上面到的写法等价于:

    @Controller
    public class EmpContrller {
        
        @RequestMapping("test")
        public String test() {
            
            return "emp/test";
        }
    }
    就算这个世道烂成一堆粪坑,那也不是你吃屎的理由
  • 相关阅读:
    59
    58
    57
    56
    55
    54
    53
    转 Using $.ajaxPrefilter() To Configure AJAX Requests In jQuery 1.5
    jquery用正则表达式验证密码强度
    什么是高内聚、低耦合?(转载)
  • 原文地址:https://www.cnblogs.com/whalesea/p/10696365.html
Copyright © 2011-2022 走看看