Package com.jfinal.core

Examples of com.jfinal.core.Controller


* Created by wangrenhui on 14-4-16.
*/
public class UrlInterceptor implements Interceptor {
  @Override
  public void intercept(ActionInvocation ai) {
    Controller controller = ai.getController();
    HttpServletRequest request = controller.getRequest();
    //webRoot
    controller.setAttr("_webRootPath", request.getScheme() + "://"
        + request.getServerName() + (request.getServerPort() == 80 ? "" : ":" + request.getServerPort())
        + request.getContextPath());

    if (!ThreadLocalUtil.isAjax()) {
      //local 数据
      controller.setAttr("_localParas", request.getQueryString());
      controller.setAttr("_localUri", ai.getActionKey());
    }
    ai.invoke();
    controller.keepPara("_webRootPath", "_localParas", "_localUri");
    //i18n
    String tmp = controller.getCookie(Const.I18N_LOCALE);
    String i18n = controller.getRequest().getLocale().toString();
    if (!i18n.equals(tmp)) {
      ai.getController().setCookie(Const.I18N_LOCALE, i18n, Const.DEFAULT_I18N_MAX_AGE_OF_COOKIE);
    }

  }
View Full Code Here

TOP

Related Classes of com.jfinal.core.Controller

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.