Reputation: 165
I want to redirect back to referrer url in playframework and I have tried to log this url after request by log function in controller:
@After
public static void log(){
session.put("referrer", request.url);
}
It works but I don't want to write the same code in every controller. When I let all the controllers extend AbstractController class(which extends play.Controller
) and put this code in to AbstracController, I received this error:
Unexpected error : Cannot read parameter names for public static void controllers.AbstractController.log()
Can anyone help me. Thanks in advance.
Upvotes: 1
Views: 4849
Reputation: 4896
try adding this method in a utility object and annotate your controllers with @With
public class ControllerUtil extends Controller{
@After
public static void log(){
session.put("referrer", request.url);
}
}
@With(ControlerUtil.class)
public MyController extends Controller{
public static index(){
render();
}
}
Alternatively annotate your log methods with @Util
UPDATE
Correct, you need to have your ControllerUtil extend Controller. If you prefer name it Application instead of ControllerUtil
Upvotes: 4