1
從Spark開始,目前嘗試通過基於http://sparkjava.com/documentation#views-and-templates文檔的Velocity使用模板。Spark Velocity - 無法加載資源(「org.apache.velocity.exception.ResourceNotFoundException」)
但我有一些錯誤。
Aug 22, 2017 2:26:43 PM org.apache.velocity.runtime.log.JdkLogChute log
SEVERE: ResourceManager : unable to find resource 'www/templates/template.html' in any resource loader.
[qtp1951434327-14] ERROR spark.http.matching.GeneralError -
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'www/templates/template.html'
目前,我有一些代碼,看起來像:
public class Minimal {
public static void main(String[] args) {
get("test", (req, res) -> {
Map<String, Object> model = new HashMap<>();
return render(model, "www/templates/template.html");
});
}
public static String render(Map<String, Object> model, String path) {
return new VelocityTemplateEngine().render(new ModelAndView(model, path));
}
}
^幾乎等同於什麼的文檔。
我已經跳過了許多關於同一問題的帖子,但是,這些解決方案似乎沒有幫助(或他們做不同),所以任何輸入將不勝感激。一些解決方案包括設置屬性(雖然它應該默認從當前目錄通過文件加載?)或將模板放在特定位置etcetc。儘管看起來不管我嘗試什麼,但它出現了同樣的錯誤。
^目前我的文件是如何設置的。