[英]How do i use spring mvc void controller method?
I am reading spring framework reference. 我正在阅读Spring框架参考。 When i read here . 当我在这里阅读。 I found that spring mvc supports returning void
types.And then i read some examples of using void
.But these examples do not make me to understand when time to use void
.Is there a better example of how to use it? 我发现spring mvc支持返回void
类型。然后我阅读了一些使用void
示例。但是这些示例使我无法理解何时使用void
。是否有更好的示例来使用它?
From the referenced document: 从引用的文档中:
"... if the method handles the response itself (by writing the response content directly, declaring an argument of type ServletResponse / HttpServletResponse for that purpose) or if the view name is supposed to be implicitly determined through a RequestToViewNameTranslator (not declaring a response argument in the handler method signature)" “ ...如果该方法自行处理响应(通过直接编写响应内容,为此声明一个ServletResponse / HttpServletResponse类型的参数),或者该视图名称应通过RequestToViewNameTranslator隐式确定(不声明响应)处理程序方法签名中的参数)”
There are two conditions listed. 列出了两个条件。
void
tells spring "I got this" and it does nothing with the response. 返回值void
告诉弹簧“我知道了”,并且它对响应没有任何作用。 RequestToViewNameTranslator
. 如果可以通过RequestToViewNameTranslator
确定视图名称。 In this situation, spring knows the view to return based on the request, so no return value is required. 在这种情况下,spring根据请求知道要返回的视图,因此不需要返回值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.