在Spring中,上下文注释有什么作用? [英] What does context annotation do in Spring?
本文介绍了在Spring中,上下文注释有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Rest API设计中,我想知道上下文注释的确切目的是什么?
In Rest API design, I am wondering what the exact purpose of the context annotation is?
private HttpServletRequest request;
@Context
public void setRequest(final HttpServletRequest req) {
request = req;
}
推荐答案
目的是指示应从上下文中设置request
属性.
The purpose is to indicate that the request
property should be set from the context.
@Context
用于从此处:
通常,@ Context可用于获取与请求或响应相关的上下文Java类型.
In general @Context can be used to obtain contextual Java types related to the request or response.
API文档(并不是非常有用的IMO.或者,也许更准确地说,是非常有用的.)
API docs (Not horribly useful IMO. Or, perhaps more accurately, horribly-useful.)
这篇关于在Spring中,上下文注释有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文