本文整理了Java中com.jfinal.core.JFinal
类的一些代码示例,展示了JFinal
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFinal
类的具体详情如下:
包路径:com.jfinal.core.JFinal
类名称:JFinal
[英]JFinal
[中]JFinal
代码示例来源:origin: JpressProjects/jpress
public String getUrl() {
return JFinal.me().getContextPath() + url;
}
代码示例来源:origin: jfinal/jfinal
/**
* Create public void afterJFinalStart() in YourJFinalConfig and
* use this method in MyJFinalConfig.afterJFinalStart() to set
* ServletContext for template loading
*/
public static void setTemplateLoadingPath(String path) {
config.setServletContextForTemplateLoading(JFinal.me().getServletContext(), path);
}
代码示例来源:origin: JpressProjects/jpress
/**
* 构建 action 的权限,每个Controller的方法对应一个action
*
* @return
*/
private static List<Permission> buildActionPermissions() {
List<Permission> permissions = new ArrayList<>();
List<String> allActionKeys = JFinal.me().getAllActionKeys();
String[] urlPara = new String[1];
for (String actionKey : allActionKeys) {
// 只处理后台的权限 和 API的权限
if (actionKey.startsWith("/admin") || actionKey.startsWith("/api")) {
Action action = JFinal.me().getAction(actionKey, urlPara);
if (action == null || excludedMethodName.contains(action.getMethodName())) {
continue;
}
AdminPermission permissionAnnotation = action.getMethod().getAnnotation(AdminPermission.class);
String text = permissionAnnotation == null ? null : permissionAnnotation.value();
String controller = action.getControllerClass().getName();
Permission permission = new Permission();
permission.setActionKey(actionKey);
permission.setNode(controller);
permission.setText(text);
permission.setType(Permission.TYPE_ACTION);
permissions.add(permission);
}
}
return permissions;
}
代码示例来源:origin: jfinal/jfinal
/**
* 将 String 数据转换为指定的类型
* @param type 需要转换成为的数据类型
* @param s 被转换的 String 类型数据,注意: s 参数不接受 null 值,否则会抛出异常
* @return 转换成功的数据
*/
public final Object convert(Class<?> type, String s) throws ParseException {
// mysql type: varchar, char, enum, set, text, tinytext, mediumtext, longtext
if (type == String.class) {
return ("".equals(s) ? null : s); // 用户在表单域中没有输入内容时将提交过来 "", 因为没有输入,所以要转成 null.
}
s = s.trim();
if ("".equals(s)) { // 前面的 String跳过以后,所有的空字符串全都转成 null, 这是合理的
return null;
}
// 以上两种情况无需转换,直接返回, 注意, 本方法不接受null为 s 参数(经测试永远不可能传来null, 因为无输入传来的也是"")
//String.class提前处理
// --------
IConverter<?> converter = converterMap.get(type);
if (converter != null) {
return converter.convert(s);
}
if (JFinal.me().getConstants().getDevMode()) {
throw new RuntimeException("Please add code in " + TypeConverter.class + ". The type can't be converted: " + type.getName());
} else {
throw new RuntimeException(type.getName() + " can not be converted, please use other type of attributes in your model!");
}
}
}
代码示例来源:origin: 94fzb/zrlog
AdminTokenThreadLocal.setAdminToken(adminTokenVO);
new File(JFinal.me().getConstants().getBaseUploadPath()).mkdirs();
String path = url;
File thumbnailFile;
thumbnailFile = new File(PathKit.getWebRootPath() + path);
} else {
bytes = IOUtil.getByteByInputStream(new FileInputStream(PathKit.getWebRootPath() + url.replace(JFinal.me().getContextPath(), "")));
path = url.substring(0, url.indexOf('.')) + "_thumbnail" + url.substring(path.indexOf('.'));
thumbnailFile = new File(PathKit.getWebRootPath() + path);
return url;
return new UploadService().getCloudUrl(JFinal.me().getContextPath(), path, thumbnailFile.getPath(), null).getUrl() + "?h=" + height + "&w=" + width;
代码示例来源:origin: com.github.sogyf/goja-mvt
return Freemarkers.renderStrTemplate("<!DOCTYPE html><html><head><title> Application 500 Eroor </title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><style type=\"text/css\">html, body {margin: 0;padding: 0;font-family : Helvetica, Arial, Sans;background: #EEEEEE;}.block {padding: 20px;border-bottom : 1px solid #aaa;}#header h1 {font-weight : normal;font-size: 28px;margin: 0;}#more {color: #666;font-size : 80%;border: none;}#header {background : #fcd2da;}#header p {color : #333;}#source {background : #f6f6f6;}#source h2 {font-weight : normal;font-size: 18px;margin: 0 0 10px 0;}#source .lineNumber {float: left;display: block;width: 40px;text-align: right;margin-right : 10px;font-size: 14px;font-family: monospace;background: #333;color: #fff;}#source .line {clear: both;color: #333;margin-bottom : 1px;}#source pre {font-size: 14px;margin: 0;overflow-x : hidden;}#source .error {color : #c00 !important;}#source .error .lineNumber {background : #c00;}#source a {text-decoration : none;}#source a:hover * {cursor : pointer !important;}#source a:hover pre {background : #FAFFCF !important;}#source em {font-style: normal;text-decoration : underline;font-weight: bold;}#source strong {font-style: normal;font-weight : bold;}</style><body><div id=\"header\" class=\"block\"><h1>Execution exception</h1><p> ${title!} </p></div><div id=\"source\" class=\"block\"><h2>Exception information in detail </h2><#list errors as er><div class=\"line <#if er?starts_with(\"\tat app.\")>error</#if>\"><span class=\"lineNumber\">${er_index + 1}:</span><pre>${er}</pre></div></#list></div></body></html>", pdata);
case SC_NOT_FOUND:
final List<String> allActionKeys = JFinal.me().getAllActionKeys();
pdata.put("routes", allActionKeys);
return Freemarkers.renderStrTemplate("<!DOCTYPE html><html><head><title>Not found</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><style type=\"text/css\">html, body {margin: 0;padding: 0;font-family: Helvetica, Arial, Sans;background: #EEEEEE;}.block {padding: 20px;border-bottom: 1px solid #aaa;}#header h1 {font-weight: normal;font-size: 28px;margin: 0;}#more {color: #666;font-size: 80%;border: none;}#header {background: #FFFFCC;}#header p {color: #333;}#routes {background: #f6f6f6;}#routes h2 {font-weight: normal;font-size: 18px;margin: 0 0 10px 0;}#routes ol {}#routes li {font-size: 14px;font-family: monospace;color: #333;}</style><body><div id=\"header\" class=\"block\"><h1>${requestURI!} Not found</h1></div><div id=\"routes\" class=\"block\"><h2>These routes have been tried, in this order :</h2><ol><#list routes as r><li> ${r} </li></#list></ol></div></body></html>", pdata);
代码示例来源:origin: yangfuhai/jboot
@Override
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
if (!webConfig.isActionCacheEnable()) {
next.handle(target, request, response, isHandled);
return;
}
Action action = JFinal.me().getAction(target, urlPara);
if (action == null) {
next.handle(target, request, response, isHandled);
return;
}
ActionCacheClear actionClear = action.getMethod().getAnnotation(ActionCacheClear.class);
if (actionClear != null) {
clearActionCache(action, actionClear);
next.handle(target, request, response, isHandled);
return;
}
EnableActionCache actionCache = getActionCache(action);
if (actionCache == null) {
next.handle(target, request, response, isHandled);
return;
}
try {
exec(target, request, response, isHandled, action, actionCache);
} finally {
ActionCacheContext.release();
}
}
代码示例来源:origin: zycgit/hasor
@Override
public ServletContext getServletContext() {
return this.jFinal.getServletContext();
}
@Override
代码示例来源:origin: com.github.sogyf/goja-test
public static void start(Class<Goja> configClass) throws Exception {
if (configStarted) {
return;
}
ClassFinder.findWithTest();
Reflect.on(Goja.class).call("initWithTest");
JFinal me = JFinal.me();
configInstance = configClass.newInstance();
initConfig(me, servletContext, configInstance);
handler = Reflect.on(me).get("handler");
configStarted = true;
configInstance.afterJFinalStart();
}
代码示例来源:origin: yangfuhai/jboot
private void debugPrintParas(Object... objects) {
if (JFinal.me().getConstants().getDevMode()) {
System.out.println("\r\n---------------Paras: " + Arrays.toString(objects) + "----------------");
}
}
代码示例来源:origin: yangfuhai/jboot
String callbackControllerKey = controllerKey + "/wechatCallback";
if (!JFinal.me().getAllActionKeys().contains(callbackControllerKey)) {
callbackControllerKey = controllerKey.substring(0, controllerKey.lastIndexOf("/")) + "/wechatCallback";
代码示例来源:origin: zycgit/hasor
/** 从 JFinal 中获取 AppContext */
public static AppContext getAppContext(JFinal jFinal) {
return RuntimeListener.getAppContext(Hasor.assertIsNotNull(jFinal, "jFinal Context is null.").getServletContext());
}
//
代码示例来源:origin: jfinal/jfinal
static String getContxtPath() {
String cp = JFinal.me().getContextPath();
return ("".equals(cp) || "/".equals(cp)) ? null : cp;
}
代码示例来源:origin: jfinal/jfinal
public static void init() {
init(com.jfinal.core.JFinal.me().getServletContext());
}
代码示例来源:origin: yangfuhai/jboot
private void debugPrintParas(Object... objects) {
if (JFinal.me().getConstants().getDevMode()) {
System.out.println("\r\n---------------Paras: " + Arrays.toString(objects) + "----------------");
}
}
代码示例来源:origin: JpressProjects/jpress
private static List<MenuItem> buildAdminMenuItems() {
List<MenuItem> adminMenuItems = new ArrayList<>();
List<String> allActionKeys = JFinal.me().getAllActionKeys();
String[] urlPara = new String[1];
for (String actionKey : allActionKeys) {
// 只处理后台的权限 和 API的权限
if (actionKey.startsWith("/admin")) {
Action action = JFinal.me().getAction(actionKey, urlPara);
if (action == null || excludedMethodName.contains(action.getMethodName())) {
continue;
}
AdminMenu adminMenu = action.getMethod().getAnnotation(AdminMenu.class);
if (adminMenu == null) {
continue;
}
MenuItem menu = new MenuItem();
menu.setText(adminMenu.text());
menu.setIcon(adminMenu.icon());
menu.setGroupId(adminMenu.groupId());
menu.setUrl(actionKey);
menu.setOrder(adminMenu.order());
adminMenuItems.add(menu);
}
}
return adminMenuItems;
}
代码示例来源:origin: zycgit/hasor
public HasorInterceptor(final JFinal jFinal) {
this.webAppContext = RuntimeListener.getAppContext(jFinal.getServletContext());
this.webAppContext = Hasor.assertIsNotNull(this.webAppContext, "need HasorPlugin.");
}
public void intercept(Invocation inv) {
代码示例来源:origin: JpressProjects/jpress
public String getDetailUrl() {
return JFinal.me().getContextPath() + "/admin/user/detail/" + getId();
}
代码示例来源:origin: 94fzb/zrlog
private void clearCache() {
JFinal.me().getServletContext().removeAttribute(Constants.CACHE_KEY);
}
代码示例来源:origin: com.jfinal/jfinal-weixin
private static String enCodeUrl(String key) {
try {
return URLEncoder.encode(key, JFinal.me().getConstants().getEncoding());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return key;
}
}
内容来源于网络,如有侵权,请联系作者删除!