Get name of Spring controller and method in view

2019-08-23 05:24发布

问题:

In a view, how would I access the name of controller and method that returned the view? This is rather straight forward in Grails, but I'm stumped on how to go about it in plain Spring.

回答1:

JSP (You are using a JSP view right?) doesn't have a ${controllerName} expression like in Grails. But you can pass the name of the controller and the method via model.



回答2:

just do in controller method

String className = this.getClass().getName();

and add classname to model.