拓展阅读
Spring Web MVC-00-重学 mvc
mvc-01-Model-View-Controller 概览
web mvc-03-JFinal
web mvc-04-Apache Wicket
web mvc-05-JSF JavaServer Faces
web mvc-06-play framework intro
web mvc-07-Vaadin
web mvc-08-Grails
JFinal
JFinal 是基于 Java 语言的极速 WEB + ORM 开发框架,其核心设计目标是开发迅速、代码量少、学习简单、功能强大、轻量级、易扩展、Restful。
自动扫描映射设计的若干缺点:引入新概念(如注解)增加学习成本、性能低、jar 包扫描可靠性与安全性低
JFinal文章来源:https://www.toymoban.com/news/detail-819966.html
Hello World
- 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>com.ryo</groupId>
<artifactId>JFinal</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>JFinal Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plugin.tomcat.version>2.2</plugin.tomcat.version>
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>jfinal</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>${plugin.tomcat.version}</version>
<configuration>
<port>8080</port>
<path>/</path>
<uriEncoding>${project.build.sourceEncoding}</uriEncoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<skipTests>true</skipTests>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
- HelloController.java
package com.ryo.controller;
import com.jfinal.core.Controller;
/**
* Created by 侯彬彬 on 2016/6/20.
*/
public class HelloController extends Controller {
public void index() {
renderText("Hello World!");
}
}
- ApplicationConfig.java
package com.ryo.controller;
import com.jfinal.config.*;
import com.jfinal.core.JFinal;
/**
* Created by 侯彬彬 on 2016/6/20.
*/
public class ApplicationConfig extends JFinalConfig {
public void configConstant(Constants constants) {
constants.setDevMode(true);
}
public void configRoute(Routes routes) {
routes.add("/hello", HelloController.class);
}
public void configPlugin(Plugins plugins) {
}
public void configInterceptor(Interceptors interceptors) {
}
public void configHandler(Handlers handlers) {
}
public static void main(String[] args) {
JFinal.start("src/main/webapp", 80, "/", 5);
}
}
- web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<filter>
<filter-name>jfinal</filter-name>
<filter-class>com.jfinal.core.JFinalFilter</filter-class>
<init-param>
<param-name>configClass</param-name>
<param-value>com.ryo.controller.ApplicationConfig</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>jfinal</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
文章来源地址https://www.toymoban.com/news/detail-819966.html
到了这里,关于java web mvc-03-JFinal的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!