I have a controller class :
@Controller
public class MyController {
@AutoWired
Service myservice
@RenderMapping
public display(){
//do work with myservice
}
}
I want to invoke the method display() from an external class but I am a null pointer exception.
Here is how I am invoking the display method from an external class :
new MyController.display()
But the instance myservice is being set to null.
How can I invoke MyController.display() and ensure the instance of myservice is not set to null ?
I think the problem is since I am creating a new instance of the controller the service is then not autowired ? But since the Spring controllers are singletons perhaps I can get access to the current instance of the controller ?
Update :
The reason I am trying this is I'm adding a config option to determine which controller display method should be implemented. Perhaps I should be using a super controller to determine which controller should be implemented ?