Jfinal Quick Start

Official website: www.jfinal.com

JFinal is a very fast WEB + ORM framework based on Java language, which is composed of Handler, Interceptor, Controller, Render and Plugin. Its core design goals are rapid development, less code, simple learning, powerful, lightweight, easy to expand, and Restful.

1. Use Eclipse to create a Dynamic Web Project

 

2. Fill in the project name, note: Target runtime must select <None>

3. Modify the Default Output Folder. The Default out folder here must be completely consistent with the WebRoot \ WEB-INF \ classes directory before you can use JFinal integrated Jetty to start the project.

 4. Modify the Content directory (WebRoot here corresponds to WebRoot \ WEB-INF \ classes in the previous step)

5. Import JFinal's jar package (copy jfinal-4.8.jar and jetty-server-2019.3.jar to the project WEB-INF \ lib)

jar package download: http://jfinal.com/download/?file=jfinal-4.8-all.zip (registration required)

jfinal-4.8-all.zip: This file contains the required common jar packages

6. Modify web.xml

<filter>
    <filter-name>jfinal</filter-name>
    <filter-class>com.jfinal.core.JFinalFilter</filter-class>
    <init-param>
       <param-name>configClass</param-name>
       <param-value>demo.DemoConfig</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>jfinal</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

7. Create a new demo package under the src directory and create a new HelloController file under the demo package

package demo;
import com.jfinal.core.Controller;
public class HelloController extends Controller {
    public void index() {
       renderText("Hello JFinal World.");
    }
}

8. Create a new DemoConfig file under the demo package

 Note: The package where the DemoConfig.java file is located and its own file name must be consistent with the configuration in the param-value tag in web.xml (in this case, the configuration is demo.DemoConfig).

package demo;
import com.jfinal.config.*;
import com.jfinal.template.Engine;
public class DemoConfig extends JFinalConfig {
    public void configConstant(Constants me) {
       me.setDevMode(true);
    }
    public void configRoute(Routes me) { me.add("/hello", HelloController.class); } public void configEngine(Engine me) {} public void configPlugin(Plugins me) {} public void configInterceptor(Interceptors me) {} public void configHandler(Handlers me) {} }

9. Configuration before starting the project

Select the project, right-click Run As-> Run Configurations to configure

Fill in the Main class input box in the right window: com.jfinal.core.JFinal

Click Run to start the project

10. Access the input in the browser: http: // localhost / hello

The output content is Hello JFinal World to prove that the project framework is completed

Guess you like

Origin www.cnblogs.com/yangy1/p/12727620.html