1. 程式人生 > >【JFinal】之 IDEA Maven 配置 JFinal(配置Tomcat)

【JFinal】之 IDEA Maven 配置 JFinal(配置Tomcat)

(1)建立Web Project

(2)構建pom.xml

這是凡凡的配置

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>cn.donald</groupId
>
<artifactId>jfinal</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>jfinal Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId
>
<artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>
2.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.jfinal</groupId> <artifactId>jfinal</artifactId> <version>3.2</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> </dependency> <dependency> <groupId>com.jfinal</groupId> <artifactId>cos</artifactId> <version>2017.5</version> </dependency> </dependencies> <build> <finalName>jfinal</finalName> </build> </project>

(3)配置Controller

IndexController.java

public class IndexController  extends Controller {
    public void index(){
        renderText("Hello Maven JFinal");
    }
}

(4)構建Config配置檔案

目錄結構

這裡寫圖片描述

JFinalMainConfig.java

這裡寫圖片描述

public class JFinalMainConfig extends JFinalConfig {


    public void configConstant(Constants me) {
        PropKit.use("a_little_config.txt");
        me.setDevMode(PropKit.getBoolean("devMode", true));
    }

    public void configRoute(Routes me) {
        me.add("/", IndexController.class);
    }

    public void configEngine(Engine me) {

    }

    public void configPlugin(Plugins me) {

    }


    public void configInterceptor(Interceptors me) {

    }


    public void configHandler(Handlers me) {

    }
}

(5)驗證

這裡寫圖片描述
這裡寫圖片描述