gatewa服务路由配置
- id: gulimall_auth_route
uri: lb://gulimall-auth-server
predicates:
- Host=auth.gulimall.com
nginx改变
将静态资源全部转移
gulimall-auth-server启动类
1. @SpringBootApplication 2. @EnableFeignClients 3. @EnableDiscoveryClient 4. public class GulimallAuthServerApplication { 5. public static void main(String[] args) { 6. SpringApplication.run(GulimallAuthServerApplication.class,args); 7. } 8. }
配置文件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
1. @Configuration 2. public class GulimallMyWebConfig implements WebMvcConfigurer { 3. 4. /** 5. * 视图映射 6. * @param registry 7. */ 8. @Override 9. public void addViewControllers(ViewControllerRegistry registry) { 10. registry.addViewController("/login.html").setViewName("login"); 11. registry.addViewController("/reg.html").setViewName("reg"); 12. } 13. }
addViewControllers:页面跳转
以前写SpringMVC的时候,如果需要访问一个页面,必须要写Controller类,然后再写一个方法跳转到页面,感觉好麻烦,其实重写WebMvcConfigurer中的addViewControllers方法即可达到效果了
在这里重写addViewControllers方法,并不会覆盖WebMvcAutoConfiguration(Springboot自动配置)中的addViewControllers(在此方法中,Spring Boot将“/”映射至index.html)
倒计时js功能代码
1. $(function () { 2. $("#sendCode").click(function () { 3. //2、倒计时 4. if($(this).hasClass("disabled")) { 5. //正在倒计时中 6. } else { 7. 8. timeoutChangeStyle(); 9. } 10. }); 11. }); 12. 13. var num = 60; 14. function timeoutChangeStyle() { 15. $("#sendCode").attr("class","disabled"); 16. if(num == 0) { 17. $("#sendCode").text("发送验证码"); 18. num = 60; 19. $("#sendCode").attr("class",""); 20. } else { 21. var str = num + "s 后再次发送"; 22. $("#sendCode").text(str); 23. setTimeout("timeoutChangeStyle()",1000); 24. } 25. num --; 26. }