JFinalConfig配置
package com.sandu.common.config; import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.ext.interceptor.SessionInViewInterceptor;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.CaseInsensitiveContainerFactory;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.render.JspRender;
import com.jfinal.render.ViewType;
import com.sandu.admin.interceptor.AdminInterceptor;
import com.sandu.admin.interceptor.GlobalActionInterceptor;
import com.sandu.admin.model._MappingKit;
import com.sandu.common.handler.CommonHandler; public class MainConfig extends JFinalConfig { /**
* 配置jfinal常量值
*/
@Override
public void configConstant(Constants me) {
//设置默认视图jsp
me.setViewType(ViewType.JSP);
//读取配置文件
PropKit.use("config.properties");
//设置当前是否为开发模式
me.setDevMode(PropKit.getBoolean("devMode"));
//设置文件上传路径
String fileUploadPath = "upload/image";
me.setBaseUploadPath(fileUploadPath);
//JspRender对HttpServletRequest对象中的数据进行了处理,数据全被放入了Map之中,设置数据不被处理
JspRender.setSupportActiveRecord(true);
} /**
* 配置接口的映射
*/
@Override
public void configRoute(Routes me) {
me.add(new AdminRoutes());
me.add(new WeixinRoutes());
} /**
* 配置数据库映射
*/
@Override
public void configPlugin(Plugins me) {
//配置数据库连接池插件
C3p0Plugin c3p0Plugin=new C3p0Plugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password"));
//orm映射 配置ActiveRecord插件
ActiveRecordPlugin arp=new ActiveRecordPlugin(c3p0Plugin);
arp.setContainerFactory(new CaseInsensitiveContainerFactory());//忽略数据库字段大小写
arp.setShowSql(true);
//数据库表与model映射
_MappingKit.mapping(arp);
//添加到插件列表中
me.add(c3p0Plugin);
me.add(arp);
} @Override
public void configInterceptor(Interceptors me) {
//添加拦截器
me.add(new GlobalActionInterceptor());
me.addGlobalServiceInterceptor(new AdminInterceptor());
//处理session传递数据找不到属性
me.add(new SessionInViewInterceptor());
} @Override
public void configHandler(Handlers me) { } public static void main(String[] args) {
JFinal.start("WebRoot", 80, "/", 5);
} }
JFinalConfig配置的更多相关文章
- JFinal 国际化
要支持国际化,需要在容器初始化的时候配置一个处理国际化的全局拦截器.比如可以使用 com.jfinal.i18n.I18nInterceptor 配置拦截器: public class MppConf ...
- JFinal 的初始化
浅析初始化过程 首先要从 web 容器进行初始化 <?xml version="1.0" encoding="UTF-8"?> <web-ap ...
- jfinal集成cas单点认证实践
本示例jfinal集成cas单点认证,采用获取到登录用户session信息后,在本地站点备份一份session信息,主要做以下几个步骤: 1.站点引入响应jar包: 2.在web.xml中配置对应过滤 ...
- jfinal的配置文件详解
1.去官网下载最新的jar包(我这是JFinal-lib-2.2) tomcat+mysql 所需要的jar 2.配置web.xml <filter> <filter-name> ...
- 【原】无脑操作:Eclipse + Maven + jFinal + MariaDB 环境搭建
一.开发环境 1.windows 7 企业版 2.Eclipse IDE for Enterprise Java Developers Version: 2019-03 (4.11.0) 3.JDK ...
- JFinal 3.3 学习 -- JFinalConfig (配置web项目)
开篇 概述 基于JFinal的web项目需要创建一个继承自JFinalConfig类的子类,该类用于对整个web项目进行配置. JFinalConfig子类需要实现六个抽象方法,如下所示: publ ...
- jfinal拦截器配置
实现aop @Before(Tx.class) public void index(){ // renderText("hello world!"); render("/ ...
- Jfianl框架定时器使用配置
Jfianl 自2.3版本后就整合了定时器到框架中,赞一个: 下面我来总结下自己使用cron4j到达定时效果的经验,不足之处还请见谅: Cron4jPlugin是作为JFinal的Plugin而存在的 ...
- JFinal常量配置学习笔记
在继承 JFinalConfig 类时,需要 实现 /** * Config constant */ public abstract void configConstant(Constants me) ...
随机推荐
- ArcEngine数据删除几种方法和性能比较[转]
四个解决方案: 1.IFeatureCursor 游标查询后,遍历删除 2.更新游标删除IFeatureCursor.DeleteFeature() 3.ITable.DeleteSearchedRo ...
- Navicat软件中mysql中int、bigint、smallint和tinyint的区别、布尔类型存储以及乱码问题的解决
很长时间不写博客了,最近一直在忙这学校的比赛都忘记更新博客了.新的任务又要开始了,我们要准备<2017年中国大学生计算机设计大赛软件服务外包竞赛>.这次不能再想像之前那样有PC端的功能作为 ...
- 【代码笔记】iOS-验证手机号,邮箱,车牌号是否合法
一,代码. - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. ...
- java实现敏感词过滤(DFA算法)
小Alan在最近的开发中遇到了敏感词过滤,便去网上查阅了很多敏感词过滤的资料,在这里也和大家分享一下自己的理解. 敏感词过滤应该是不用给大家过多的解释吧?讲白了就是你在项目中输入某些字(比如输入xxo ...
- centos 6 YUM安装 lmp
准备篇: 1.配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m t ...
- php foreach引用赋值
在写代码时发现php foreach引用赋值会导致意外的行为. 代码示例: <?php $arr = array('a','b','c'); foreach($arr as $k=>&am ...
- Atitit.http代理的实现 代码java php c# python
Atitit.http代理的实现 代码java php c# python 1. 代理服务器用途 代理服务器看成是一种扩展浏览器功能的途径.例如,在把数据发送给浏览器之前,可以用代理服务器压缩数据 调 ...
- SQL Server 如何通过SQL语句定位SSRS中的具体报表
在一些IT技术人员的推广.简单培训后,公司很多部门都有一些非IT技术人员参与开发各自需求的Reporting Service报表.原因很简单,罗列出来的原因大概有这样一些: IT部门的考量: 1:IT ...
- 使用fdisk给新增加硬盘分区
1.使用fdisk创建6个分区[1P+1E(5L)] //dev/sdb1 /dev/sdb5 /dev/sdb6 /dev/sdb7 /dev/sdb8 /deb/sdb9 [root@serv ...
- appscan 对api的手工检测
AppScan 在 API 安全测试中的实例介绍 在本项目中,API 遵循标准的的 REST 架构和背端服务器进行通信.针对 API 的功能测试由两部分组成:一部分是用一个 Web 的测试页面直接实现 ...