开发者

Struts redirect from model

开发者 https://www.devze.com 2022-12-10 09:02 出处:网络
I\'m trying to implement a security model where the model of secured pages inherits from a SecureSupport. I don\'t know how or if I can redirect from a constructor, however. See below:

I'm trying to implement a security model where the model of secured pages inherits from a SecureSupport. I don't know how or if I can redirect from a constructor, however. See below:

public class SecureSupport extends ActionSupport {
    private Map session;

    public SecureSupport  throws Exception
    {
        session = ActionContext.getContext().getSession();

        if(!session.containsKey("User"))
        {
            // redirect from here
        }
        return开发者_JS百科 SUCCESS;
    }


Make your own exception (ie NoUserException) which has to be a run time exception. Then catch this exception with global exception handler, there you can redirect anywhere you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消