spring boot controller in view

is it required to define view with spring controller autowire parameter in constructor to use spring controller. Can it work with just as global variable autowire in view.

No, it’s not required. I would recommend using constructor injection, though, as field injection is more error-prone.

ok, with field its not working. works with constructor only.
how to manage it in main view with applayout when there are multiple views with its multiple spring services. because I think it will require to pass all spring services in main app layout’s constructor to call sub views with service parameters.

It works fine with field injection, but there is a difference in that with field injection, the field will be null during the constructor. Use [@PostConstruct]
(https://www.baeldung.com/spring-postconstruct-predestroy) on a method which will then be invoked once the injected field is available.

Using constructor injection, the injected instance will already be available during the constructor. This is why it’s easier to just do it this way.