Get name of Spring controller and method in view

2019-08-23 05:50发布

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.

2条回答
Deceive 欺骗
2楼-- · 2019-08-23 06:05

just do in controller method

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

and add classname to model.

查看更多
beautiful°
3楼-- · 2019-08-23 06:15

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.

查看更多
登录 后发表回答