Spring MVC控制器方法参数如何工作? [英] How does Spring MVC controller method parameter work?

查看:163
本文介绍了Spring MVC控制器方法参数如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用从STS创建的模板创建了一个Spring MVC项目,这是在控制器中生成的:

I created a Spring MVC project using a template that is created from the STS and this is what is generated in the controller:

@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
    //stuff
}

我的问题是,区域设置 model 变量被传递到 home 方法?

My question is, how does the locale and model variable get passed into the home method?

此外,什么是可以传递给方法的对象的可能选项?

Also, what are the possible options for the objects that can be passed to the method?

推荐答案

一般的答案是Spring magic;但是,支持的处理程序方法Spring参考指南的MVC章节中的参数和返回类型具有您问题的确切答案。

The general answer is "Spring magic"; however, "Supported handler method arguments and return types" in the MVC chapter of the Spring reference guide has the exact answers to your questions.

这篇关于Spring MVC控制器方法参数如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆