Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure JFinal

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to configure JFinal, which is very detailed and has a certain reference value. Friends who are interested must finish it!

Environment description:

Program version

JRE1.8

Tomcat7.0

Maven3.1.1

Intellij IDEA14.0.3

First, create a new Project

★ opens IDEA,Create New Project

★ builds Project through Maven, but does not use templates

Fill in the relevant names of Project in ★ and complete the creation of Project. Here the Project is named "jfinal-demo"

Second, change the current Project into a POM project.

As the parent project of the project, the project is used to define the version and coding mode of the packages that each module depends on.

★ deletes the src directory

★ edits the pom.xml under the root directory and sets the packaging format to pom.

Pom.xml of ★ parent project

4.0.0jfinallydemojfinalMube parentpom1.0 buy SNAPSHOTUTFue 82.24.12 junitjunit$ {junit.version} com.jfinaljfinal$ {jfinal.version} ${project.artifactId} org.apache.maven.pluginsmaven-resources-plugin2.7 ${project.build.sourceEncoding} org.apache.maven.pluginsmaven-compiler-plugin3.21.71.7 ${project.build.sourceEncoding} org.apache.tomcat.maventomcat7-maven-plugin2.280/

Advertising is the driving force of persistence, click on advertising, is the greatest support for me!

3. New Module (module) "jfinal-web"

★ right-click the jfinal-demo directory to create a new child Module

Choose to use a template when creating a ★

After the ★ is created, the directory results are shown below

Fourth, write code for testing

★ create a new java directory under the main directory of the jfinal-web module

★ marks the newly created java directory as Sources Root, so that IDEA will treat the .java files in that directory as java source files

★ adds dependencies to the "jfinal-web" module. The version is already defined in the parent project, so you don't need to fill in version here.

Pom.xml of the ★ "jfinal-web" module

Jfinal-parentjfinal-demo1.0-SNAPSHOT4.0.0jfinal-webwarjfinal-web Maven Webapp http://maven.apache.orgjunitjunittestcom.jfinaljfinaljfinal-web

★ creates the Controller class "HelloController.java" for testing

The ★ class inherits the com.jfinal.core.Controller class and implements the index method

★ com.demo.controller.HelloController

Packagecom.demo.controller;importcom.jfinal.core.Controller;publicclassHelloControllerextendsController {publicvoidindex () {renderText ("hello world!");}}

★ creates the Config class "DemoConfig.java" for testing

The ★ class inherits the com.jfinal.config.JFinalConfi class and overrides five methods. Press the Alt+Insert shortcut key to generate code quickly

★ notice that the route "/ hello" is added here to define which controller is called when accessing the http://localhost/hello.

★ com.demo.config.DemoConfig

Packagecom.demo.config;importcom.demo.controller.HelloController;importcom.jfinal.config.*;publicclassDemoConfigextendsJFinalConfig {@ OverridepublicvoidconfigConstant (Constants me) {me.setDevMode (true);} @ OverridepublicvoidconfigRoute (Routes me) {me.add ("/ hello", HelloController.class);} @ OverridepublicvoidconfigPlugin (Plugins me) {} @ OverridepublicvoidconfigInterceptor (Interceptors me) {} @ OverridepublicvoidconfigHandler (Handlers me) {}

5. Configure the running environment

★ operates according to the picture, regardless of why.

Configure the filter of web.xml to ensure that all access can be blocked by JFinal

★ web.xml

"- / Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/dtd/web-app_2_3.dtd" > jfinal-demojfinalcom.jfinal.core.JFinalFilterconfigClasscom.demo.config.DemoConfigjfinal/*

7. Start the application

★ startup completed

★, open a browser to test it.

The above is all the content of this article "how to configure JFinal". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report