Spring MVC Controller: 查询股票信息 @RequestMapping("/code")
该代码是一个Spring MVC框架的Controller,使用'@RequestMapping'注解映射了请求路径为'/code'的GET请求。其中,'@RequestParam'注解用于绑定请求参数,即'key'。在方法中,通过调用stockCache的getStocks方法获取符合条件的StockInfo集合,并将其封装在CounterRes对象中返回。
@RequestMapping("/code")
public CounterRes stockQuery(@RequestParam String key) {
Collection<StockInfo> stocks = stockCache.getStocks(key);
return new CounterRes(stocks);
}
原文地址: https://www.cveoy.top/t/topic/oT2r 著作权归作者所有。请勿转载和采集!