Reputation: 4773
I want to set a application variable in spring MVC Can I do just like this
@Scope("globalSession")
public class ApplicationVariable{
public static appVar;
}
Will this variable be available throughout the application? Or is there any other better way to do this?
Upvotes: 0
Views: 1489
Reputation: 6283
By default spring beans are singleton so it will be always available in global scope. in your above example you should just keep ApplicationVariable bean as singleton scope, keep variable to instance instead of static and inject bean whenever you need variables.
Upvotes: 2