第0课--预热作业

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>预热作业</title>
	<style>
		body,p,input{
			padding:0;margin:0;
		}
		a{
			text-decoration:none;
		}
		body{
			padding:20px;
			background:#f1f1f1;
		}
		#oDiv{
			width:100px;
			height:100px;
			background:#fff;
			border:2px solid black;
		}
		p input{
			width:60px;
			height:30px;
			background-color:red;
		}
		#seting{
			width:260px;
			height:140px;
			background-color:#999;
			padding:20px;
			position:absolute;
			left:700px;
			top:200px;
			display:none;
		}
		#box{
			width:208px;
			height:124px;
			background-color:#fff;
			padding:8px 26px;
		}
		#seting #box p{
			font:14px/30px "宋体";
			color:#000;
		}
		#seting #box p span{
			padding:2px;
		}
		#box input{
			width:60px;
			height:30px;
			background-color:blue;
			color:#fff;
		}
		input[type = "reset"]{
			margin-left:40px;
		}
		a{
			padding:2px;
			background-color:#e7e7e7;
			color:#000;
		}
		a:hover{
			background-color:#e54346;
			color:#000;
		}
		</style>
		<script>
			window.onload = function(){
				var oButton = document.getElementById("button");
				var oSeting = document.getElementById("seting");
				var oBody = document.getElementById("body");
				var oSetWithLittle = document.getElementById("set_width_little");
				var oSetWithMiddle= document.getElementById("set_width_middle");
				var oSetWithBig= document.getElementById("set_width_big");
				var oSetHeightLittle = document.getElementById("set_height_little");
				var oSetHeightMiddle= document.getElementById("set_height_middle");
				var oSetHeightBig= document.getElementById("set_height_big");
				var oSetRed = document.getElementById("set_red");
				var oSetBlue= document.getElementById("set_blue");
				var oSetYellow= document.getElementById("set_yellow");
				var oDiv = document.getElementById("oDiv");
				var oReset = document.getElementById("reset");
				var oSubmite = document.getElementById("submit");

				oButton.onclick = function(){
					oSeting.style.display = "block";
					oBody.style.background = "#808080";
				}

				oSetWithLittle.onclick = function(){
					oDiv.style.width = "200px";
				}

				oSetWithMiddle.onclick = function(){
					oDiv.style.width = "300px";
				}

				oSetWithBig.onclick = function(){
					oDiv.style.width = "400px";
				}

				oSetHeightLittle.onclick = function(){
					oDiv.style.height = "200px";
				}

				oSetHeightMiddle.onclick = function(){
					oDiv.style.height = "300px";
				}

				oSetHeightBig.onclick = function(){
					oDiv.style.height = "400px";
				}

				oSetRed.onclick = function(){
					oDiv.style.background = "red";
				}

				oSetBlue.onclick = function(){
					oDiv.style.background = "blue";
				}

				oSetYellow.onclick = function(){
					oDiv.style.background = "yellow";
				}
				oReset.onclick = function(){
					oDiv.style.width = "100px";
					oDiv.style.height = "100px";
					oDiv.style.background = "#fff";
				}

				oSubmite.onclick = function(){
					oSeting.style.display = "none";
					oBody.style.background = "#f1f1f1";
				}
			}
		</script>
</head>
<body id = "body">
	<p>请为下面的DIV设置样式:<input type = "button" value = "点击设置"/ id = "button"></p>
	<div id = "oDiv"></div>
	<div id = "seting">
		<div id = "box">
			<p>请选择背景色:
				<span id = "set_red" style = "background-color:#9cce00">红</span>
				<span id = "set_yellow" style = "background-color:#efbd00">黄</span>
				<span id = "set_blue" style = "background-color:#5a94ef">蓝</span>
			</p>
			<p>请选择宽(px):
				<a href = "#"><span id = "set_width_little">200</span></a>
				<a href = "#"><span id= "set_width_middle">300</span></a>
				<a href = "#"><span id= "set_width_big">400</span></a>
			</p>
			<p>请选择高(px):
				<a href = "#"><span id = "set_height_little">200</span></a>
				<a href = "#"><span id= "set_height_middle">300</span></a>
				<a href = "#"><span id= "set_height_big">400</span></a>
			</p>
			<input type = "reset" value = "恢复"/ id = "reset"><input type = "submit" value = "确定"/ id = "submit">
		</div>
	</div>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Spring Boot 中,可以通过实现 `ApplicationRunner` 接口,在应用程序启动时预热 DynamicServerListLoadBalancer。 以下是一个简单的示例代码: ```java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient; import org.springframework.cloud.netflix.ribbon.SpringClientFactory; import org.springframework.stereotype.Component; import java.util.List; @Component public class LoadBalancerPreheat implements ApplicationRunner { @Autowired private DiscoveryClient discoveryClient; @Autowired private SpringClientFactory springClientFactory; @Override public void run(ApplicationArguments args) throws Exception { // 获取服务列表 List<ServiceInstance> instances = discoveryClient.getInstances("your-service-name"); // 获取 RibbonLoadBalancerClient 实例 RibbonLoadBalancerClient loadBalancerClient = springClientFactory.getLoadBalancerClient("your-service-name"); // 更新服务列表 loadBalancerClient.updateListOfServers(instances); // 等待一段时间,以确保服务列表已经更新 Thread.sleep(5000); } } ``` 在这个示例中,`LoadBalancerPreheat` 类实现了 `ApplicationRunner` 接口,重写了 `run` 方法。在 `run` 方法中,首先通过 `DiscoveryClient` 获取指定服务的实例列表,然后通过 `SpringClientFactory` 获取 `RibbonLoadBalancerClient` 实例,并使用 `updateListOfServers` 方法更新服务列表。最后,等待一段时间,以确保服务列表已经更新。 需要注意的是,服务列表可能会发生变化,因此需要定期更新服务列表。可以使用定时任务或者监听服务注册中心的事件来实现服务列表的自动更新。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值