Spark is a
free and open-source software
Free and open-source software (FOSS) is a term used to refer to groups of software consisting of both free software and open-source software where anyone is freely licensed to use, copy, study, and change the software in any way, and the source ...
web application framework
A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs. Web frameworks provide a standard way to build and ...
and
domain-specific language written in
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
. It is an alternative to other Java web application frameworks such as
JAX-RS
Jakarta RESTful Web Services, (JAX-RS; formerly Java API for RESTful Web Services) is a Jakarta EE application programming interface, API specification that provides support in creating web services according to the Representational State Transf ...
,
Play framework
Play Framework is an open-source web application framework which follows the model–view–controller (MVC) architectural pattern. It is written in Scala and usable from other programming languages that are compiled to JVM bytecode, e.g. Java. ...
and
Spring MVC
Spring(s) may refer to:
Common uses
* Spring (season), a season of the year
* Spring (device), a mechanical device that stores energy
* Spring (hydrology), a natural source of water
* Spring (mathematics), a geometric surface in the shape of a he ...
. It runs on an embedded
Jetty
A jetty is a structure that projects from land out into water. A jetty may serve as a breakwater, as a walkway, or both; or, in pairs, as a means of constricting a channel. The term derives from the French word ', "thrown", signifying somet ...
web server by default, but can be configured to run on other webservers.
Inspired by
Sinatra, it does not follow the
model–view–controller
Model–view–controller (MVC) is a software architectural pattern commonly used for developing user interfaces that divide the related program logic into three interconnected elements. This is done to separate internal representations of infor ...
pattern used in other frameworks, such as Spring MVC. Instead, Spark is intended for "quickly creating web-applications in Java with minimal effort."
Spark was created and open-sourced in 2011 by Per Wendel, and was completely rewritten for version 2 in 2014. The rewrite was hugely centered on the Java 8 lambda philosophy, so Java 7 is officially not supported in version 2 and above.
Example (Hello World)
import static spark.Spark.*;
public class HelloWorld
Supported template engines
Spark supports these template engines:
Views and Templates - Documentation - Spark Framework: An expressive web framework for Kotlin and Java
/ref>
*Apache Velocity
Apache Velocity first released in April 2001, is a Java-based template engine that provides a template language to reference objects defined in Java code. It aims to ensure clean separation between the presentation tier and business tiers in a ...
*FreeMarker
Apache FreeMarker is a free Java-based template engine, originally focusing on dynamic web page generation with MVC software architecture. However, it is a general purpose template engine, with no dependency on servlets or HTTP or HTML, and is ...
*Mustache
A moustache (; en-US, mustache, ) is a strip of facial hair grown above the upper lip. Moustaches have been worn in various styles throughout history.
Etymology
The word "moustache" is French, and is derived from the Italian ''mustaccio'' ...
* Handlebars
Jade
*Thymeleaf
Thymeleaf is a Java XML/XHTML/HTML5 template engine that can work both in web (servlet-based) and non-web environments. It is better suited for serving XHTML/HTML5 at the view layer of MVC-based web applications, but it can process any XML file e ...
*Pebble
Water
*jTwig
*Jinjava
Jetbrick
References
External links
*{{Official website, https://sparkjava.com/
Spark's GitHub repository
Free software
Java platform software
Web frameworks