jFinal 2.2入門學習之一:搭建架構輸出helloword

來源:互聯網
上載者:User

標籤:

官方推薦用Eclipse IDE for Java EE Developers 做為開發環境

1、建立 Dynamic Web Project

 

2、修改 Default Output Folder,推薦輸入 WebRoot\WEB-INF\classes

3、修改 Content directory,推薦輸入 WebRoot

4、去官網下載最新的jfinal架構(我這是JFinal-2.2)

 

把jetty-server-8.1.8.jar jfinal-2.2-bin.jar和jfinal-2.2-bin-with-src.jar放到項目 WEB-INF\lib下,jetty-server-8.1.8.jar是開發時使用的運行環境,用tomact和生產環境下就不需要了

5、修改WebRoot/WEB-INF下的web.xml(filter-name需與工程名一致)

<?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_demo</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_demo</filter-name><url-pattern>/*</url-pattern></filter-mapping></web-app>

 

6、在項目 src 目錄下建立 demo 包,並在 demo 包下建立 DemoConfig 檔案,   內容如下:

package demo;import com.jfinal.config.*;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 configPlugin(Plugins me){}public void configInterceptor(Interceptors me){}public void configHandler(Handlers me){}}

 7、在 demo 包下建立 HelloController 類檔案,  內容如下:

 

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

 

8、右擊DemoConfig檔案

此處可以產生連接埠號碼80衝突問題

需設定

WebRoot 8081 / 5

-XX:PermSize=64M -XX:MaxPermSize=256M

9、瀏覽器輸入http://localhost:8081/hello輸出內容為 Hello JFinal World 證明項目架構搭建完成。

 

jFinal 2.2入門學習之一:搭建架構輸出helloword

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.