一個Hello World火花:如何使用Spark Java返回靜態html頁面?
get(new Route("/hello") {
@Override
public Object handle(Request request, Response response) {
response.type("text/html");
return "<h1>Hello Spark MVC Framework!</h1>";
}
});
我怎樣才能返回一個靜態index.html文件呢?
注:
- 我需要這樣的index.html是在火花的java簡單的精神罐子
- ,我想避免儘可能打算通過模板,即對於一個靜態頁面來說是過分的了。
謝謝!然後,如何在get方法中返回這個文件? – seinecle
所有的靜態文件都是通過get方法返回的。要查看您的index.html,只需打開瀏覽器並鍵入http:// localhost:4567 –
我有幾個問題。在Spark Java中,靜態資源目錄在哪裏?另外,如果路由處理/ hello /,如果index.html文件被放置在/ hello /?最後,我們可以使用.JSP文件嗎? – codeshark