简体   繁体   English

关于Spring MVC Web应用程序开发中的实例

[英]Regarding Instance in Spring mvc web application development

I am new to spring mvc web development. 我是Spring MVC Web开发的新手。 I have one query. 我有一个查询。 Suppose we are having different service classes. 假设我们有不同的服务类别。 So do we have one instance of those classes per request OR only single instance of that class gets create. 因此,对于每个请求,我们是否具有这些类的一个实例,或者仅创建该类的单个实例。 Actually i want to use instance variables , so with each request new instance will get created or it will be like singleton type of behavior. 实际上,我想使用实例变量,因此对于每个请求,都会创建新实例,或者就像是单例行为。 Hopefully i am able to explain my question. 希望我能解释我的问题。

you can have either, the default is a singleton - one instance. 您可以选择其中一个,默认为单例-一个实例。 But this can be changed using bean scope. 但这可以使用bean范围更改。

obligatory link to offical docs correct chapter 强制链接到官方文档正确的章节

(personally never needed to use anything other singleton) (个人不需要使用任何其他单例)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM