나는이 FTL에 다음 코드 :는`나누기
<#macro field label name value="" type="text">
${name}
${name!"print if null"}
<div class="field">
<div class="clearfix" id="${name}_field">
<label for="${name}">${label}</label>
<div class="input">
<input type="${type}" id="${name}" name="${name}" value="${value}">
<span class="help-inline"></span>
<span class="help-block"></span>
</div>
</div>
</div>
</#macro>
<@field label="label" name="test" />
그리고는이 인쇄되어
foo-test
test
<div class="field">
<div class="clearfix" id="foo-test_field">
<label for="foo-test">label</label>
<div class="input">
<input type="text" id="foo-test" name="foo-test" value="">
<span class="help-inline"></span>
<span class="help-block"></span>
</div>
</div>
</div>
foo-test
내 응용 프로그램의 이름입니다 만 왜 거기에 인쇄되고 있는지 이해할 수 없다. foo-test
을 검색하기 위해 Ctrl + F를 사용했다. ftl이나 컨트롤러에 아무 것도 없다.
이 외에도 name
은 내 응용 프로그램의 이름을 가진 변수입니다. 그런데 왜 두 번째 인쇄가 매크로에 전달 된 올바른 값을 인쇄하나요 ??
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-template-freemarker</artifactId>
<version>2.0.0</version>
</dependency>
플러그인이 있습니다 : 이것은 ... 내가 메이븐을 사용하고 난이 종속성이 너무 촉발
정말 이상하다
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<mainClass>com.example.foo.foo-test</mainClass>
</configuration>
</plugin>
</plugins>
</build>
그리고 내 컨트롤러는 다음과 같습니다
를.....
import spark.ModelAndView;
import spark.Spark;
import spark.template.freemarker.FreeMarkerEngine;
......
Spark.get("/foo", (request, response) -> {
Map<String, Object> attributes = new HashMap<>();
return new ModelAndView(attributes, "test.ftl");
}, new FreeMarkerEngine());
Maven을 사용하고 있습니까? –
@AleksandrM 예,이 문제와 관련이 있습니까? –
maven에서 ftl-s를 어떻게 포장하고 있습니까? pom.xml을 보여줄 수 있습니까? –