zoukankan      html  css  js  c++  java
  • SpringMvc4.x---快捷的ViewController

    @RequestMapping("/index")
        public  String hello(){
    
            return "index";
        }

    此处无任何的业务处理,只是简单的页面跳转,写了至少三行有效的代码,在实际的开发中会涉及大量这样的页面转向,若都这样写会特别的麻烦,我们通过在配置类MyMvcConfig里通过重写addViewControllers来简化配置:

    public class MyMvcConfig extends WebMvcConfigurerAdapter {
    
    ......... @Override
    public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/index").setViewName("/index");
        registry.addViewController("/toUpload").setViewName("/upload");
        registry.addViewController("/converter").setViewName("/converter");
    } }
  • 相关阅读:
    iOS基础
    iOS基础
    iOS基础
    iOS基础
    iOS基础
    iOS基础
    iOS基础
    简单DP + 高精
    高精度计算
    树 (tree)
  • 原文地址:https://www.cnblogs.com/dsitn/p/7203357.html
Copyright © 2011-2022 走看看