Spark Java 프레임 워크에 익숙하며 Freemarker 템플릿 엔진을 사용하여 HTML 파일을 렌더링하려고합니다. 하지만 내 CSS 및 JS 파일을 렌더링 할 수 없습니다.Spark Java Template Engine을 사용하여 css 및 js 파일을 렌더링 할 수 없습니다.
public static void main(String[] args) {
BasicConfigurator.configure();
staticFileLocation("/css");
staticFileLocation("/Content/Images");
staticFileLocation("/fonts");
staticFileLocation("/js");
final Configuration configuration = new Configuration();
configuration.setClassForTemplateLoading(Spark.class, "/");
get("/searchview", (request, response) -> {
StringWriter writer = new StringWriter();
try {
Template searchTemplate = configuration.getTemplate("templates/search.ftl");
searchTemplate.process(null, writer);
} catch (Exception e) {
halt(500);
}
return writer;
});
}
을 내가 URL을 입력 할 때 현재 : 로컬 호스트 : 4567/searchview을 내 HTML 페이지가 렌더링됩니다 다음과 같이
./pom.xml
./src/main/java/Spark.java
./src/main/resources/css/bootstrap.css
./src/main/resources/js/bootstrap.min.js
./src/main/resources/js/app.js
./src/main/resources/templates/search.ftl
주요 방법은 다음과 같이
내 프로젝트 구조입니다 하지만 CSS와 JS는 그렇지 않습니다. 내 콘솔에서
말한다 그것을 : 정보 spark.http.matching.MatcherFilter - 요청 된 경로 [/css/bootstrap.min.css] 내가 놓친 게 무엇
스파크
에 매핑되지?