gatewa服务路由配置
   
- id: gulimall_auth_route
  uri: lb://gulimall-auth-server
  predicates:
    - Host=auth.gulimall.com
    nginx改变
   
    
     
      将静态资源全部转移
     
    
   
    
   
    
   
    gulimall-auth-server启动类
   
@SpringBootApplication
@EnableFeignClients
@EnableDiscoveryClient
public class GulimallAuthServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(GulimallAuthServerApplication.class,args);
    }
}
    配置文件application.properties
   
spring.cloud.nacos.config.server-addr=127.0.0.1:8848 spring.application.name=gulimall-auth-server server.port=20000 spring.thymeleaf.cache=false
    配置类GulimallMyWebConfig
   
@Configuration
public class GulimallMyWebConfig implements WebMvcConfigurer {
    /**
     * 视图映射
     * @param registry
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/login.html").setViewName("login");
        registry.addViewController("/reg.html").setViewName("reg");
    }
}
addViewControllers:页面跳转
以前写SpringMVC的时候,如果需要访问一个页面,必须要写Controller类,然后再写一个方法跳转到页面,感觉好麻烦,其实重写WebMvcConfigurer中的addViewControllers方法即可达到效果了
在这里重写addViewControllers方法,并不会覆盖WebMvcAutoConfiguration(Springboot自动配置)中的addViewControllers(在此方法中,Spring Boot将“/”映射至index.html)
![]()
    倒计时js功能代码
   
    $(function () {
        $("#sendCode").click(function () {
            //2、倒计时
            if($(this).hasClass("disabled")) {
                //正在倒计时中
            } else {
                timeoutChangeStyle();
            }
        });
    });
    var num = 60;
    function timeoutChangeStyle() {
        $("#sendCode").attr("class","disabled");
        if(num == 0) {
            $("#sendCode").text("发送验证码");
            num = 60;
            $("#sendCode").attr("class","");
        } else {
            var str = num + "s 后再次发送";
            $("#sendCode").text(str);
            setTimeout("timeoutChangeStyle()",1000);
        }
        num --;
    }
    
   
 
版权声明:本文为m0_62436868原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。