1) It doesn't run out of the box. It misses a dependency:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.13</version>
</dependency>
2) The after filter is NOT triggered.
So, I went back to version 2.3
3) The StaticFileLocation does not set the content-type header, so Internet Explorer 11 does not use the CSS file. I took me a while to figure that out.
Add this:
after("/css/*.css", (request, response) -> {
response.type("text/css");
});
Addition 1 june 2016:
Quick fix for problem 2 and 3:
Download the spark-master at GitHub. Unpack the zip.
2)
In the file StaticFilesConfiguration.java change the consume method into:
public boolean consume(HttpServletRequest httpRequest,
HttpServletResponse httpResponse) throws IOException {
String url = httpRequest.getRequestURL(). toString();
if (url.endsWith(".css")) {
httpResponse.setContentType(" text/css");
}
if ( consumeWithFileResourceHandler s(httpRequest, httpResponse)) {
return true;
}
if ( consumeWithJarResourceHandler( httpRequest, httpResponse)) {
return true;
}
return false;
}
3)
in the POM.xml
change:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</ artifactId>
<version>1.7.13</version>
<scope>test</scope>
</dependency>
into:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</ artifactId>
<version>1.7.13</version>
</dependency>
Do -> mvn clean install
And you got your 2.6-SNAPSHOT
Reference it with:
<dependency>
<groupId>com.sparkjava</ groupId>
<artifactId>spark-core</ artifactId>
<version>2.6-SNAPSHOT</ version>
</dependency>
Geen opmerkingen:
Een reactie posten