@chenbinghua
2019-03-02T07:16:13.000000Z
字数 1454
阅读 607
java
根据jfinal官方手册开发
http://www.jfinal.com/doc/1-2
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>jfinal</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>jetty-server</artifactId>
<version>8.1.8</version>
<!-- 调试的时候compile 打包的时候provided-->
<scope>compile</scope>
</dependency>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<filter>
<filter-name>jfinal</filter-name>
<filter-class>com.jfinal.core.JFinalFilter</filter-class>
<init-param>
<param-name>configClass</param-name>
<param-value>com._520it.jfinaldemo.common.DemoConfig</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>jfinal</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
表示项目启动的时候加载com.jfinal.core.JFinalFilter过滤器,并制定配置类为com.demo.common.DemoConfig,创建JFinal相关类。
/* 并且拦截所有请求
com.demo.common.DemoConfig
public void configRoute(Routes routes) {
routes.add("/hello", HelloController.class);
}
在DemoConfig创建main方法
public static void main(String[] args) {
// 制定项目根目录,端口号,上下文路径
JFinal.start("src/main/webapp", 80, "/");
}