周末总结-第二周

2019.3.10 星期天 晴雨阴

多进程运行的一周

  1. 对于上学期挖的大坑,继续进行弥补,准备补考。
  2. 每天坚持写python代码,提高编程能力,目标就是独立完成一个项目。
  3. 安装了虚拟机与Ubuntu linux 操作系统,学习了一些简单的终端命令。
  4. 还有就是日常的课程学习。这学期都是一些要背记的东西。感觉没有什么吸引力。

总结
就是感觉每天高强度的去学习,等到了晚上的时候,整个人的效率感觉已经没了。看书看不进去了,有必要去调整一下自己的学习安排。把喜欢的、感兴趣的放在晚上。还有就是好的一点是,坚持周内不玩游戏,等到了周末游戏的瘾也就没有之前那么大了。
之前看到过知乎上一个问题:

那些超级自律的人最后都怎么样了?

自己也要做一个高度自律的人,按时起床,服从计划,心怀理想,积极向上!

在Spring Boot应用中,如果你想要允许跨域请求并在周末(周六、周日)特定时间开启Access-Control-Allow-Origin策略,你可以创建一个自定义过滤器(Filter),例如使用`@CrossOrigin`注解,并通过`@PreAuthorize`或`@ConditionalOnDate`来控制其生效的时间。 首先,创建一个定制的过滤器,比如`WeekendCorsFilter.java`: ```java import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; @Configuration @Component public class WeekendCorsFilter { private final ManagementServerProperties management; public WeekendCorsFilter(ManagementServerProperties management) { this.management = management; } @Bean(name = "weekendCorsFilter") public WebMvcConfigurer corsConfigurer() { return (configurer) -> { configurer.addCorsConfiguration( "/**", // 允许所有的路径 headers -> { if (isWeekend()) { // 检查是否为周末 headers.setAllowCredentials(true); // 设置允许凭证 headers.addAllowedHeader("*"); // 允许所有头信息 headers.addAllowedMethod("*"); // 允许所有HTTP方法 headers.addAllowedOrigin("*"); // 允许来自任何源的请求 } else { // 非周末则按默认设置或你自己的规则处理 configurer.cors().allowCredentials(false); configurer.cors().allowedOrigins("http://your-origin.com"); } }); }; } private boolean isWeekend() { String[] daysOfWeek = {"Saturday", "Sunday"}; for (String day : daysOfWeek) { if (management.getEndpointProperties().getWeb().getDatepatterns().contains(day)) { return true; // 如果找到对应的日期模式,则为周末 } } return false; } } ``` 然后在启动类或Spring Boot Actuator配置中启用这个过滤器: ```java @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Autowired private WeekendCorsFilter weekendCorsFilter; // ... @PostConstruct public void init() { weekendCorsFilter.corsConfigurer(); // 加载配置 } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值