com.jfinal.core.Controller Java Examples
The following examples show how to use
com.jfinal.core.Controller.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArticleSearchPageDirective.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onRender(Env env, Scope scope, Writer writer) { Controller controller = JbootControllerContext.get(); String keyword = controller.getAttr("keyword"); int page = controller.getAttr("page"); int pageSize = getParaToInt("pageSize", scope, 10); Page<Article> dataPage = StrUtil.isNotBlank(keyword) ? articleService.search(keyword, page, pageSize) : null; if (dataPage != null) { scope.setGlobal("articlePage", dataPage); } //需要页面自行判断 articlePage 是否为空 renderBody(env, scope, writer); }
Example #2
Source File: ChangePwdValidator.java From jboot-admin with Apache License 2.0 | 6 votes |
@Override protected void validate(Controller c) { String pwd = c.getPara("user.pwd"); String newPwd = c.getPara("newPwd"); String rePwd = c.getPara("rePwd"); validateRequiredString("user.pwd", "旧密码不能为空"); validateRequiredString("newPwd", "新密码不能为空"); validateRequiredString("rePwd", "确认密码不能为空"); if(!newPwd.equals(rePwd)){ addError("两次输入密码不一致,请重新输入!"); } User user = AuthUtils.getLoginUser(); if(!AuthUtils.checkPwd(pwd, user.getPwd(), user.getSalt2())){ addError("原密码不正确!"); } }
Example #3
Source File: ResValidator.java From jboot-admin with Apache License 2.0 | 6 votes |
@Override protected void validate(Controller c) { String methodName = getActionMethod().getName(); if ("postAdd".equals(methodName)) { validateRequiredString("pid", "父资源编码为空"); validateRequiredString("res.name", "资源名称为空"); validateRequiredString("res.url", "资源URL为空"); validateRequiredString("res.des", "资源描述为空"); validateRequiredString("res.type", "资源类型为空"); validateRequiredString("res.seq", "排序号为空"); validateRequiredString("res.status", "资源状态为空"); } else if ("postUpdate".equals(methodName)) { validateRequiredString("pid", "父资源编码为空"); validateRequiredString("res.name", "资源名称为空"); validateRequiredString("res.url", "资源URL为空"); validateRequiredString("res.des", "资源描述为空"); validateRequiredString("res.type", "资源类型为空"); validateRequiredString("res.seq", "排序号为空"); validateRequiredString("res.status", "资源状态为空"); } }
Example #4
Source File: IocInterceptor.java From jfinal-ext3 with Apache License 2.0 | 6 votes |
public void intercept(Invocation ai) { Controller controller = ai.getController(); Field[] fields = controller.getClass().getDeclaredFields(); for (Field field : fields) { Object bean = null; if (field.isAnnotationPresent(Inject.BY_NAME.class)) bean = ctx.getBean(field.getName()); else if (field.isAnnotationPresent(Inject.BY_TYPE.class)) bean = ctx.getBean(field.getType()); else continue ; try { if (bean != null) { field.setAccessible(true); field.set(controller, bean); } } catch (Exception e) { throw new RuntimeException(e); } } ai.invoke(); }
Example #5
Source File: NotNullParaInterceptor.java From jboot-admin with Apache License 2.0 | 6 votes |
private void renderError(Invocation inv, String param, String errorRedirect) { if (StrUtils.isNotBlank(errorRedirect)) { inv.getController().redirect(errorRedirect); return; } Controller controller = inv.getController(); if (controller instanceof JbootController) { JbootController jc = (JbootController) controller; if (jc.isAjaxRequest()) { jc.renderJson(RestResult.buildError("参数["+param+"]不可为空")); return; } } controller.setAttr(BusinessExceptionInterceptor.MESSAGE_TAG, "参数["+param+"]不可为空").render(exceptionView); }
Example #6
Source File: TemplateManager.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
/** * 获取预览的模板 * * @return */ public Template getPreviewTemplate() { if (!JPressConfig.me.isTemplatePreviewEnable()) { return null; } Controller controller = JbootControllerContext.get(); if (controller == null) { return null; } String tId = controller.getPara("template"); if (StrUtil.isBlank(tId)) { return null; } return getTemplateById(tId); }
Example #7
Source File: CookieUtil.java From jboot with Apache License 2.0 | 6 votes |
public static String get(Controller ctr, String key, String secretKey) { String cookieValue = ctr.getCookie(key); if (cookieValue == null) { return null; } try { String value = new String(Base64Kit.decode(cookieValue)); return getFromCookieInfo(secretKey, value); } //倘若 cookie 被人为修改的情况下能会出现异常情况 catch (Exception ex) { LogKit.error(ex.toString(), ex); } return null; }
Example #8
Source File: ControllerUtil.java From jboot with Apache License 2.0 | 6 votes |
/** * 参考ActionMapping中的实现。 * * @param controllerClass * @param method * @param controllerKey * @return */ public static String createActionKey(Class<? extends Controller> controllerClass, Method method, String controllerKey) { String methodName = method.getName(); String actionKey; ActionKey ak = method.getAnnotation(ActionKey.class); if (ak != null) { actionKey = ak.value().trim(); if ("".equals(actionKey)) { throw new IllegalArgumentException(controllerClass.getName() + "." + methodName + "(): The argument of ActionKey can not be blank."); } if (!actionKey.startsWith(SLASH)) { actionKey = SLASH + actionKey; } } else if (methodName.equals("index")) { actionKey = controllerKey; } else { actionKey = controllerKey.equals(SLASH) ? SLASH + methodName : controllerKey + SLASH + methodName; } return actionKey; }
Example #9
Source File: SmartField.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
public Object doGetDataFromControllerByName(String name) { Controller controller = JbootControllerContext.get(); if (name.contains(".")) { String[] modelAndAttr = name.split("\\."); String modelName = modelAndAttr[0]; String attr = modelAndAttr[1]; Object object = controller.getAttr(modelName); if (object == null) { return null; } else if (object instanceof Model) { return ((Model) object).get(attr); } else if (object instanceof Map) { return ((Map) object).get(attr); } else { try { Method method = object.getClass().getMethod("get" + StrKit.firstCharToUpperCase(attr)); return method.invoke(object); } catch (Exception e) { e.printStackTrace(); } return null; } } else { return controller.getAttr(name); } }
Example #10
Source File: TokenInterceptor.java From jfinal-api-scaffold with MIT License | 6 votes |
@Override public void intercept(ActionInvocation ai) { Controller controller = ai.getController(); String token = controller.getPara("token"); if (StringUtils.isEmpty(token)) { controller.renderJson(new BaseResponse(Code.ARGUMENT_ERROR, "token can not be null")); return; } User user = TokenManager.getMe().validate(token); if (user == null) { controller.renderJson(new BaseResponse(Code.TOKEN_INVALID, "token is invalid")); return; } controller.setAttr("user", user); ai.invoke(); }
Example #11
Source File: MsgInterceptor.java From jfinal-weixin with Apache License 2.0 | 6 votes |
/** * 检测签名 */ private boolean checkSignature(Controller controller) { String signature = controller.getPara("signature"); String timestamp = controller.getPara("timestamp"); String nonce = controller.getPara("nonce"); if (StrKit.isBlank(signature) || StrKit.isBlank(timestamp) || StrKit.isBlank(nonce)) { controller.renderText("check signature failure"); return false; } if (SignatureCheckKit.me.checkSignature(signature, timestamp, nonce)) { return true; } else { logger.error("check signature failure: " + " signature = " + controller.getPara("signature") + " timestamp = " + controller.getPara("timestamp") + " nonce = " + controller.getPara("nonce")); return false; } }
Example #12
Source File: LimitFallbackProcesserDefault.java From jboot with Apache License 2.0 | 6 votes |
/** * 处理 Controller 的限流 * * @param resource * @param inv */ protected void doProcessWebLimit(String resource, Invocation inv) { Controller controller = inv.getController(); controller.getResponse().setStatus(config.getDefaultHttpCode()); if (RequestUtil.isAjaxRequest(controller.getRequest())) { controller.renderJson(config.getDefaultAjaxContent()); } //非ajax的正常请求 else { String limitView = config.getDefaultHtmlView(); if (limitView != null) { controller.render(limitView); } else { controller.renderText("reqeust limit."); } } }
Example #13
Source File: ActivitiKit.java From my_curd with Apache License 2.0 | 6 votes |
/** * 接收流程审批表单参数 * 表单的 name 字段必须 是 "fp_" 开头 * 例如 "fp_auditResult-审批结果" * * @param controller * @return */ public static Map<String, Object> getFormParams(Controller controller) { Map<String, Object> ret = new LinkedHashMap<>(); Map<String, String[]> properties = controller.getParaMap(); for (Map.Entry<String, String[]> entry : properties.entrySet()) { String name = entry.getKey(); String[] value = entry.getValue(); // 表单字段必须是 fp_ 开头 if (!name.startsWith("fp_")) { continue; } if (value.length == 1) { ret.put(name, value[0]); } else { ret.put(name, Joiner.on(",").join(value)); } } log.debug("form properties: {}", ret.toString()); return ret; }
Example #14
Source File: VisitLogInterceptor.java From my_curd with Apache License 2.0 | 6 votes |
@Override public void intercept(Invocation inv) { Controller controller = inv.getController(); SysVisitLog sysVisitLog = new SysVisitLog(); sysVisitLog.setId(IdUtils.id()); sysVisitLog.setSysUserIp(WebUtils.getRemoteAddress(controller.getRequest())); sysVisitLog.setSysUser(WebUtils.getSessionUsername(controller)); sysVisitLog.setUrl(inv.getActionKey()); sysVisitLog.setRequestType(controller.getRequest().getMethod()); sysVisitLog.setCreateTime(new Date()); Map<String, String[]> params = controller.getRequest().getParameterMap(); if (params.keySet().size() > 0) { sysVisitLog.setParam(JSON.toJSONString(params)); // if (sysVisitLog.getParam().length() > 100) { // sysVisitLog.setParam("超长文本参数"); // } } sysVisitLog.save(); inv.invoke(); }
Example #15
Source File: SessionInViewInterceptor.java From my_curd with Apache License 2.0 | 6 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) public void intercept(Invocation inv) { inv.invoke(); Controller c = inv.getController(); if (c.getRender() instanceof com.jfinal.render.JsonRender) { return; } HttpSession hs = c.getSession(false); if (hs != null) { Map session = new com.jfinal.ext.interceptor.SessionInViewInterceptor.JFinalSession(hs); for (String sessionField : sessionFields) { session.put(sessionField, hs.getAttribute(sessionField)); } c.setAttr("session", session); } }
Example #16
Source File: WechatInterceptor.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
/** * 获取当前的url * * @param controller * @return */ public static String getGotoUrl(Controller controller) { HttpServletRequest req = controller.getRequest(); // 获取用户将要去的路径 String queryString = req.getQueryString(); // 被拦截前的请求URL String url = req.getScheme() + "://" + req.getServerName() + req.getRequestURI(); if (StrUtil.isNotBlank(queryString)) { url = url.concat("?").concat(queryString); } return StrUtil.urlEncode(url); }
Example #17
Source File: JPressInterceptor.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void intercept(Invocation inv) { Controller controller = inv.getController(); //方便模板开发者直接在模板里接收参数 controller.setAttr("C", controller); controller.setAttr("CDN", JPressOptions.getCDNDomain()); controller.setAttr(ADDON_PATH_KEY, ADDON_PATH_VALUE); Enumeration<String> paraKeys = controller.getParaNames(); if (paraKeys != null) { while (paraKeys.hasMoreElements()) { String key = paraKeys.nextElement(); // 有很多 options 字段的 model,为了扩展 model 本身的内容 // 为了安全起见,不让客户端提交 .options 对 model 本身的 options 字段进行覆盖 if (key != null && key.endsWith(".options")) { LogKit.error("paras has options key :" + key); controller.renderError(404); return; } } } inv.invoke(); }
Example #18
Source File: ParaDirective.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onRender(Env env, Scope scope, Writer writer) { Controller controller = JbootControllerContext.get(); String key = getPara(0, scope); String defaultValue = getPara(1, scope); if (StrUtil.isBlank(key)) { throw new IllegalArgumentException("#para(...) argument must not be empty" + getLocation()); } String value = controller.getPara(key); if (StrUtil.isBlank(value)) { value = StrUtil.isNotBlank(defaultValue) ? defaultValue : ""; } try { writer.write(value); } catch (IOException e) { e.printStackTrace(); } }
Example #19
Source File: AddonControllerManager.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
public static void addController(Class<? extends Controller> controllerClass, String addonId) { RequestMapping mapping = controllerClass.getAnnotation(RequestMapping.class); if (mapping == null) { return; } String path = AnnotationUtil.get(mapping.value()); if (path == null) { return; } // 尝试去清除 Controller 以保障绝对安全, 虽然插件在 stop() 的时候会去清除 // 但是由于可能 stop() 出错等原因,没有执行到 deletController 的操作 deleteController(controllerClass); String viewPath = AnnotationUtil.get(mapping.viewPath()); if (StrUtil.isBlank(viewPath)) { viewPath = "/"; } else if (viewPath.indexOf("/") != 0) { viewPath = "/" + viewPath; } addonRoutes.add(path, controllerClass, "/addons/" + addonId + viewPath); controllerAddonMapping.put(controllerClass, addonId); }
Example #20
Source File: UserInterceptor.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void intercept(Invocation inv) { Controller c = inv.getController(); User user = c.getAttr(JPressConsts.ATTR_LOGINED_USER); if (user != null) { //购物车的相关信息 setUserCartInfoAttrs(inv, user); inv.invoke(); return; } String uid = CookieUtil.get(c, JPressConsts.COOKIE_UID); if (StrUtil.isBlank(uid)) { inv.invoke(); return; } user = userService.findById(uid); if (user != null) { c.setAttr(JPressConsts.ATTR_LOGINED_USER, user); setUserCartInfoAttrs(inv, user); } inv.invoke(); }
Example #21
Source File: ArticleModuleInitializer.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override public String onRenderDashboardBox(Controller controller) { List<Article> articles = Aop.get(ArticleService.class).findListByColumns(Columns.create().eq("status", Article.STATUS_NORMAL), "id desc", 10); controller.setAttr("articles", articles); ArticleCommentService commentService = Aop.get(ArticleCommentService.class); List<ArticleComment> articleComments = commentService.findListByColumns(Columns.create().ne("status", ArticleComment.STATUS_TRASH), "id desc", 10); controller.setAttr("articleComments", articleComments); return "article/_dashboard_box.html"; }
Example #22
Source File: AdminInterceptor.java From zrlog with Apache License 2.0 | 5 votes |
/** * 为了规范代码,这里做了一点类是Spring的ResponseEntity的东西,及通过方法的返回值来判断是应该返回页面还会对应JSON数据 * 具体方式看 AdminRouters,这里用到了 ThreadLocal * * @param ai */ private void adminPermission(Invocation ai) { Controller controller = ai.getController(); AdminTokenVO adminTokenVO = adminTokenService.getAdminTokenVO(controller.getRequest()); if (adminTokenVO != null) { try { User user = new User().findById(adminTokenVO.getUserId()); if (StringUtils.isEmpty(user.getStr("header"))) { user.set("header", Constants.DEFAULT_HEADER); } controller.setAttr("user", user); controller.setAttr("protocol", adminTokenVO.getProtocol()); TemplateHelper.fullTemplateInfo(controller, false); if (!"/admin/logout".equals(ai.getActionKey())) { adminTokenService.setAdminToken(user, adminTokenVO.getSessionId(), adminTokenVO.getProtocol(), controller.getRequest(), controller.getResponse()); } ai.invoke(); // 存在消息提示 if (controller.getAttr("message") != null) { initIndex(controller.getRequest()); controller.render(new FreeMarkerRender("/admin/index.ftl")); } else { if (!tryDoRender(ai, controller)) { controller.renderHtml(IOUtil.getStringInputStream(new FileInputStream(PathKit.getWebRootPath() + Constants.NOT_FOUND_PAGE))); } } } catch (Exception e) { LOGGER.error("", e); exceptionHandler(ai, e); } finally { AdminTokenThreadLocal.remove(); } } else if ("/admin/login".equals(ai.getActionKey()) || "/api/admin/login".equals(ai.getActionKey())) { ai.invoke(); tryDoRender(ai, controller); } else { blockUnLoginRequestHandler(ai); } }
Example #23
Source File: PermissionInterceptor.java From my_curd with Apache License 2.0 | 5 votes |
@Override public void intercept(Invocation inv) { boolean flag = true; Controller controller = inv.getController(); // 验证菜单权限 RequirePermission requirePermission = inv.getClass().getAnnotation(RequirePermission.class); List<String> codes; if (requirePermission != null ) { codes = requirePermission.isPermission() ? controller.getSessionAttr("menuCodes") : controller.getSessionAttr("roleCodes"); flag = codes.contains(requirePermission.value()); } if (flag) { // 菜单权限通后 再验证按钮权限 requirePermission = inv.getMethod().getAnnotation(RequirePermission.class); if (requirePermission != null) { codes = requirePermission.isPermission() ? controller.getSessionAttr("buttonCodes") : controller.getSessionAttr("roleCodes"); flag = codes.contains(requirePermission.value()); } } if (flag) { // 菜单权限、按钮权限 都具备 放行 inv.invoke(); return; } // 无权限响应 String requestType = inv.getController().getHeader("X-Requested-With"); if ("XMLHttpRequest".equals(requestType) || StringUtils.notEmpty(inv.getController().getPara("xmlHttpRequest"))) { Ret ret = Ret.create().setFail().set("msg", "无权限操作!您的行为已被记录到日志。"); // 其实并没有,可以自行扩展 controller.renderJson(ret); } else { controller.render("/WEB-INF/views/common/no_permission.ftl"); } }
Example #24
Source File: SearchSql.java From my_curd with Apache License 2.0 | 5 votes |
public void intercept(Invocation ai) { Controller c = ai.getController(); // 查询字段前缀 String prefix = "search_"; // 获得 查询 参数 Map<String, Object> searchParams = getParametersStartingWith(c.getRequest(), prefix); // 获得 查询 所有的 查询 filter Map<String, SearchFilter> filters = SearchFilter.parse(searchParams); // 根据 filter 获得 wheresql 语句 String whereSql = buildFilter(filters.values()); c.setAttr(Constant.SEARCH_SQL, whereSql); int pageNumber = c.getParaToInt("page", 1); int pageSize = c.getParaToInt("rows", 1); //分页参数, 兼容 bootstrap 分页 和 easyui grid 分页 // int pageNumber; // int pageSize; // if (StrKit.notBlank(c.getPara("offset"))) { // // bootstraptable 分页 // pageNumber = c.getParaToInt("offset", 0); // pageSize = c.getParaToInt("limit", 10); // if (pageNumber != 0) {// 获取页数 // pageNumber = pageNumber / pageSize; // } // pageNumber += 1; // } else { // // easyui grid 分页 // pageNumber = c.getParaToInt("page", 1); // pageSize = c.getParaToInt("rows", 1); // } c.setAttr("pageNumber", pageNumber); c.setAttr("pageSize", pageSize); ai.invoke(); }
Example #25
Source File: AutoBindRoutes.java From jfinal-ext3 with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public AutoBindRoutes addExcludeClasses(Class<? extends Controller>... clazzes) { if (clazzes != null) { for (Class<? extends Controller> clazz : clazzes) { excludeClasses.add(clazz); } } return this; }
Example #26
Source File: ProductValidate.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void intercept(Invocation inv) { Controller c = inv.getController(); Long productId = inv.getController().getLong("id"); Product product = productService.findById(productId); if (product == null || !product.isNormal()) { if (RequestUtil.isAjaxRequest(c.getRequest())) { c.renderJson(Ret.fail().set("code", "2").set("message", "商品不存在或已下架。")); } else { c.renderError(404); } return; } User user = UserInterceptor.getThreadLocalUser(); if (user == null) { if (RequestUtil.isAjaxRequest(c.getRequest())) { c.renderJson(Ret.fail() .set("code", 1) .set("message", "用户未登录") .set("gotoUrl", JFinal.me().getContextPath() + "/user/login?gotoUrl=" + product.getUrl())); } else { c.redirect("/user/login?gotoUrl=" + product.getUrl()); } return; } c.setAttr(ATTR_PRODUCT,product); inv.invoke(); }
Example #27
Source File: TemplateInterceptor.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void intercept(Invocation inv) { Controller controller = inv.getController(); controller.setAttr(JPressConsts.ATTR_WEB_TITLE, StrUtil.escapeHtml(webTitle)); controller.setAttr(JPressConsts.ATTR_WEB_SUBTITLE, StrUtil.escapeHtml(webSubTitle)); controller.setAttr(JPressConsts.ATTR_WEB_NAME, StrUtil.escapeHtml(webName)); controller.setAttr(JPressConsts.ATTR_WEB_IPC_NO, StrUtil.escapeHtml(webIpcNo)); controller.setAttr(JPressConsts.ATTR_SEO_TITLE, StrUtil.escapeHtml(seoTitle)); controller.setAttr(JPressConsts.ATTR_SEO_KEYWORDS, StrUtil.escapeHtml(seoKeyword)); controller.setAttr(JPressConsts.ATTR_SEO_DESCRIPTION, StrUtil.escapeHtml(seoDescription)); controller.setAttr(JPressConsts.ATTR_WEB_DOMAIN, webDomain); controller.setAttr(JPressConsts.ATTR_WEB_COPYRIGHT, webCopyright); //添加CSRF的配置,方便在前台进行退出等操作 String uuid = StrUtil.uuid(); inv.getController().setCookie(CSRFInterceptor.CSRF_KEY, uuid, -1); inv.getController().setAttr(CSRFInterceptor.CSRF_ATTR_KEY, uuid); MenuService menuService = Aop.get(MenuService.class); List<Menu> menus = menuService.findListByType(Menu.TYPE_MAIN); SortKit.toTree(menus); controller.setAttr(JPressConsts.ATTR_MENUS, menus); Template template = TemplateManager.me().getCurrentTemplate(); controller.setAttr("TPATH", template == null ? "" : template.getRelativePath()); inv.invoke(); }
Example #28
Source File: AddonManager.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
private void addControllers(AddonInfo addonInfo) { List<Class<? extends Controller>> controllerClasses = addonInfo.getControllers(); if (controllerClasses != null) { for (Class<? extends Controller> c : controllerClasses) { AddonControllerManager.addController(c, addonInfo.getId()); } } }
Example #29
Source File: AddonManager.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
private void deleteControllers(AddonInfo addonInfo) { List<Class<? extends Controller>> controllerClasses = addonInfo.getControllers(); if (controllerClasses != null) { for (Class<? extends Controller> c : controllerClasses) { AddonControllerManager.deleteController(c); } } }
Example #30
Source File: AdminInterceptor.java From zrlog with Apache License 2.0 | 5 votes |
/** * 尝试通过Controller的放回值来进行数据的渲染 * * @param ai * @param controller * @return true 表示已经渲染数据了,false 表示并未按照约定编写,及没有进行渲染 */ private boolean tryDoRender(Invocation ai, Controller controller) { Object returnValue = ai.getReturnValue(); if (ai.getMethod().getAnnotation(RefreshCache.class) != null) { cacheService.refreshInitDataCache(GlobalResourceHandler.CACHE_HTML_PATH, controller, true); if (JFinal.me().getConstants().getDevMode()) { LOGGER.info("{} trigger refresh cache", controller.getRequest().getRequestURI()); } } boolean rendered = false; if (returnValue != null) { if (ai.getActionKey().startsWith("/api/admin")) { controller.renderJson((Object) ai.getReturnValue()); rendered = true; } else if (ai.getActionKey().startsWith("/admin") && returnValue instanceof String) { //返回值,约定:admin 开头的不写模板类型,其他要写全 if (!returnValue.toString().endsWith(".jsp") && returnValue.toString().startsWith("/admin")) { String templatePath = returnValue.toString() + ".ftl"; if (AdminInterceptor.class.getResourceAsStream(Constants.FTL_VIEW_PATH + templatePath) != null) { controller.render(new FreeMarkerRender(templatePath)); rendered = true; } else { rendered = false; } } else { controller.render(returnValue.toString()); rendered = true; } } } else { rendered = true; } return rendered; }