參考Vertx文件
Vertx是router base,有很多方便的handle,想要讓Vertx支援靜態檔案,當web server,只要加入
router.route("/static/*").handler(StaticHandler.create());
將靜態資源(css、js、html...等),放入webroot資料夾底下就行了,如果還有子資料夾,存取路徑就加上資料夾名稱就好。
在webroot底下路徑是http://localhost:8080/static/
如果在webroot/css底下路徑就是http://localhost:8080/static/css/
如果要包成fat jar記得要在main下開一個resources當作webroot,打包時才會將檔案包進去。
程式參考
還有些可以講的是
Vertx是router base,有很多方便的handle,想要讓Vertx支援靜態檔案,當web server,只要加入
router.route("/static/*").handler(StaticHandler.create());
將靜態資源(css、js、html...等),放入webroot資料夾底下就行了,如果還有子資料夾,存取路徑就加上資料夾名稱就好。
在webroot底下路徑是http://localhost:8080/static/
如果在webroot/css底下路徑就是http://localhost:8080/static/css/
如果要包成fat jar記得要在main下開一個resources當作webroot,打包時才會將檔案包進去。
程式參考
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.vertx.example; | |
import io.vertx.core.AbstractVerticle; | |
import io.vertx.ext.jdbc.JDBCClient; | |
import io.vertx.ext.web.Router; | |
import io.vertx.ext.web.handler.StaticHandler; | |
public class HelloWorldVerticle extends AbstractVerticle { | |
@Override | |
public void start() { | |
Router router = Router.router(vertx); | |
router.route("/static/*").handler(StaticHandler.create()); | |
vertx.createHttpServer().requestHandler(router::accept).listen(8080); | |
} | |
} |
- gzip
- cache
- ssl
有緣再說囉XD
成果是找廁所無障礙網頁板
成果是找廁所無障礙網頁板
留言
張貼留言
有什麼想法歡迎跟我們分享