Spring Boot 控制器准备Spring Boot Controller
在一个空的 Spring Initializr 骨架里写出六个 REST 端点,五个测试全过。Write six REST endpoints in an empty Spring Initializr skeleton, with all five tests passing.
只准备 Federation 考试里那道 Spring Boot 控制器题。Preparing only for the Spring Boot controller task in the Federation assessment.
这条计划的全程The whole route
学Learn
学:这道题要读懂的两节Learn: the two lessons this task needs
你在这You are here一节讲给你的骨架里那几个 Spring 注解和一个请求走过的路,一节讲六个端点 —— 状态码就是这道题的全部。One covers the Spring annotations in the skeleton you are given and the path a request takes; the other covers the six endpoints, where the status codes are the whole task.
练Practice
练:这两节的练习,加一个 Java Debug LabPractice: those lessons' exercises, plus one Java debug lab
「六个端点全 return null 也过了 3 个」这件事就在这几个练习里 —— 测试通过不等于做对了。These exercises are where you meet the fact that returning null from all six endpoints still passes three tests. Green does not mean correct.
- 找不到订单时该怎么处理What to do when the order is not found
- 这三个参数注解各从哪取值Where each of these parameter annotations reads from
- POST 创建成功该返回什么What a successful POST should return
- 为什么 return null 能骗过三个测试Why return null fools three of the tests
- 补全三个关键端点的状态码与调用Fill in the status codes and calls of three key endpoints
- 不看答案,自己写出全部六个端点Write all six endpoints yourself, without looking at the answer
- Debug Lab · 查一个不存在的订单,返回了 200Debug Lab · Asking for an order that does not exist returns 200
- 故障 4 · PATCH 传了小写状态,返回 500Fault 4 · PATCH sends a lowercase status and gets a 500
写Code
写:六个端点Code: the six endpoints
本机跑:方法、路径、状态码、参数来源、校验、异常处理。基线是 5 run / 2 failures。Run it locally: method, path, status code, where each parameter comes from, validation, exception handling. The baseline is 5 run / 2 failures.
空手做Rebuild
空手做:从零重写控制器Rebuild: the controller from nothing
空文件夹或一个空的 Spring Initializr 骨架,75 分钟,没有提示。这一档才是真实考试的样子。An empty folder or an empty Spring Initializr skeleton, 75 minutes, no hints. This tier is what the real thing looks like.
正在读这台浏览器里的进度…Reading your progress from this browser…
计划里每一格的完成状态都是已有进度的一个视图 —— 以前自己刷过的八股、做过的练习一条都不会白做,跟着计划做完的 也照样在 课程 里打勾。 换计划、不跟计划都不动任何记录。Every square here is a view of progress you already have. Questions you rated and exercises you solved before picking a plan all count, and anything you finish inside a plan is still ticked in the courses. Changing plans or stopping never touches a record.