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 --;
}