GithubHelp home page GithubHelp logo

JAVA 极速WEB+ORM框架 JFinal

中文 English

JFinal 是基于 Java 语言的极速 WEB + ORM 框架,其核心设计目标是开发迅速、代码量少、学习简单、功能强大、轻量级、易扩展、Restful。在拥有Java语言所有优势的同时再拥有 ruby、python 等动态语言的开发效率!为您节约更多时间,去陪恋人、家人和朋友 ;)

JFinal有如下主要特点

  • MVC 架构,设计精巧,使用简单
  • 遵循 COC 原则,支持零配置,无 XML
  • 独创 Db + Record 模式,灵活便利
  • ActiveRecord 支持,使数据库开发极致快速
  • 极简、强大、高性能模板引擎 Enjoy,十分钟内掌握 90% 用法
  • 自动加载修改后的 Java 文件,开发过程中无需重启服务
  • AOP支持,拦截器配置灵活,功能强大
  • Plugin 体系结构,扩展性强
  • 多视图支持,支持 Enjoy、FreeMarker、JSP
  • 强大的 Validator 后端校验功能
  • 功能齐全,拥有传统 SSH 框架的绝大部分核心功能
  • 体积小仅 832 KB,并且无第三方依赖

JFinal 极速开发微信公众号欢迎你的加入: JFinal

Maven 坐标

<dependency>
    <groupId>com.jfinal</groupId>
    <artifactId>jfinal</artifactId>
    <version>5.1.1</version>
</dependency>

以下是JFinal实现Blog管理的示例:

1. 控制器(支持 Enjoy、JSP、JSON等等以及自定义视图渲染)

@Before(BlogInterceptor.class)
public class BlogController extends Controller {

    @Inject
    BlogService service;

    public void index() {
        set("blogPage", service.paginate(getInt(0, 1), 10));
        render("blog.html");
    }

    public void add() {
    }

    @Before(BlogValidator.class)
    public void save() {
        getModel(Blog.class).save();
        redirect("/blog");
    }

    public void edit() {
        set("blog", service.findById(getInt()));
    }

    @Before(BlogValidator.class)
    public void update() {
        getModel(Blog.class).update();
        redirect("/blog");
    }

    public void delete() {
        service.deleteById(getInt());
        redirect("/blog");
    }
}

2.Service所有业务与sql全部放在Service层

public class BlogService {

    private Blog dao = new Blog().dao();
    
    public Page<Blog> paginate(int pageNumber, int pageSize) {
        return dao.paginate(pageNumber, pageSize, "select *", "from blog order by id asc");
    }
    
    public Blog findById(int id) {
        return dao.findById(id);
    }
    
    public void deleteById(int id) {
        dao.deleteById(id);
    }
}

3.Model(无xml、无annotaion、无attribute)

public class Blog extends Model<Blog> {
    
}

4.Validator(API引导式校验,比xml校验方便N倍,有代码检查不易出错)

public class BlogValidator extends Validator {
    protected void validate(Controller controller) {
        validateRequiredString("blog.title", "titleMsg", "请输入Blog标题!");
        validateRequiredString("blog.content", "contentMsg", "请输入Blog内容!");
    }

    protected void handleError(Controller controller) {
        controller.keepModel(Blog.class);
    }
}

5.拦截器(在此demo中仅为示例,本demo不需要此拦截器)

public class BlogInterceptor implements Interceptor {
    public void intercept(Invocation inv) {
        System.out.println("Before invoking " + inv.getActionKey());
        inv.invoke();
        System.out.println("After invoking " + inv.getActionKey());
    }
}

更多支持

  • JFinal 官方网站 https://jfinal.com
  • 扫码关注官方微信公众号,第一时间尊享最新动向

JFinal

James Zhan's Projects

2048 icon 2048

A small clone of 1024 (https://play.google.com/store/apps/details?id=com.veewo.a1024)

acme.sh icon acme.sh

A pure Unix shell script implementing ACME client protocol

activej icon activej

ActiveJ is an alternative Java platform built from the ground up. ActiveJ redefines web, high load, and cloud programming in Java, featuring ultimate performance and scalability!

adminlte icon adminlte

AdminLTE - Free Premium Admin control Panel Theme That Is Based On Bootstrap 3.x

android-app icon android-app

OSCHINA 的 Android 客户端源码,可在 Google Play 或者国内几个应用市场上搜索“开源**”来安装此app

annotated_deep_learning_paper_implementations icon annotated_deep_learning_paper_implementations

🧑‍🏫 60 Implementations/tutorials of deep learning papers with side-by-side notes 📝; including transformers (original, xl, switch, feedback, vit, ...), optimizers (adam, adabelief, sophia, ...), gans(cyclegan, stylegan2, ...), 🎮 reinforcement learning (ppo, dqn), capsnet, distillation, ... 🧠

at.js icon at.js

Add Github like mentions autocomplete to your application.

autosize icon autosize

Autosize is a small, stand-alone script to automatically adjust textarea height to fit text.

aviator icon aviator

A high performance scripting language hosted on the JVM.

awesome-ai-gpts icon awesome-ai-gpts

Awesome AI GPTs, OpenAI GPTs, GPT-4, ChatGPT, GPTs, Prompts, plugins, Prompts leaking

awesome-mac icon awesome-mac

 This repo is a collection of awesome Mac applications and tools for developers and designers.

baguajie icon baguajie

A Pinterest likely application which also involves LBS and SNS.

baota icon baota

宝塔Linux面板 - 简单好用的服务器运维面板

bluetoothprint icon bluetoothprint

android 蓝牙打印机(ESC/POS 热敏打印机),打印菜单小票和图片,对蓝牙配对和连接打印功能进行了封装,让你超快实现蓝牙打印功能。

bootstrap-table icon bootstrap-table

An extended Bootstrap table with radio, checkbox, sort, pagination, and other added features. (supports twitter bootstrap v2, v3 and v4)

bootstrap-vue icon bootstrap-vue

BootstrapVue provides one of the most comprehensive implementations of Bootstrap v4 for Vue.js. With extensive and automated WAI-ARIA accessibility markup.

bootstrap4-zhcn-documentation icon bootstrap4-zhcn-documentation

基于bootstrapv4.x最新的中文简体手册,这是Bootstrap官方认同的简体翻译版本,也是目前最完整的Bootstrap4中文翻译版,由Zoomla!逐浪CMS团队维护(最近版本:Bootstrap v4.3.1)

bootstrapvue-cn icon bootstrapvue-cn

BootstrapVue中文手册,由Bootstrap中文站(http://code.z01.com/v4)官方团队翻译支持,一套将全球最流行的前端框架Bootstap与**最流行的前端webpack库Vue完美结合的框架,精良翻译,服务国人。

bulma icon bulma

Modern CSS framework based on Flexbox

byte-buddy icon byte-buddy

Runtime code generation for the Java virtual machine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.