我使用从 STS 创建的模板创建了一个 Spring MVC 项目,这就是 Controller 中生成的内容:
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
//stuff
}
我的问题是,locale
和 model
变量如何传递到 home
方法中?
此外,可以传递给该方法的对象有哪些可能的选项?
最佳答案
一般答案是“Spring magic”;然而,"Supported handler method arguments and return types" Spring 引用指南的 MVC 章节对您的问题有准确的答案。
关于java - Spring MVC Controller 方法参数如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49281407/