freemarker tutorials

https://github.com/freemarker/freemarker-tutorials

00-running-a-server-locally

**Libraries Used**

* [FreeMarker 2.3.23](http://freemarker.org/docs/)
* [Spring MVC 4.2](https://spring.io/blog/2015/07/31/spring-framework-4-2-goes-ga)
* Javax Servlet API 3.1.0

## Step 1: Download or clone the FreeMarker Tutorials project

[Download and extract the FreeMarker Tutorials Github project](https://github.com/freemarker/freemarker-tutorials/archive/master.zip) or clone it using git (git clone https://github.com/freemarker/freemarker-tutorials.git)

## Step 2: Compile the Hello World project

Open up a console window (Command prompt for Windows users or Terminal for OS X users) and navigate to the tutorials/01-hello-world directory. Run mvn compile war:inplace.

bsh
mvn compile war:inplace

(If you don’t have Maven, follow the installation instructions here: [Installing Java and Maven](../00-installing-java-and-maven/))

This will download the dependencies and compile the Java files.

## Step 3: Point Tomcat at your webapp directory

1. In the [previous tutorial](../00-running-a-server-locally) we set up a Tomcat server. Make sure your server is still running!

* Windows users: Open up Command Prompt, type catalina start and press enter
* OS X users: Open up Terminal, type catalina start and press enter

2. Navigate to your Tomcat installation folder, and find the conf/Catalina/localhost directory and create a context file called **hello-world.xml**.

* Windows users: If you followed the previous tutorial’s instructions, Windows users can navigate directly to the folder by copying and pasting %CATALINA_HOME%\conf\Catalina\localhost into a Windows explorer window.

![Windows 7 XML file](images/win7-catalina-home.png)

* OS X users: In Terminal you can do this (Replace **8.0.26** with your version of Tomcat):

bsh
cd /usr/local/Cellar/tomcat/8.0.26/libexec/conf/Catalina/localhost
vi hello-world.xml

在${tomcat_home}/conf/Catalina/localhost新建一个文件hello-world.xml

3. Inside hello-world.xml, add the following (Replace **PATH_TO_FREEMARKER_TUTORIALS** with
wherever you have the FreeMarker tutorials project.):

xml
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="PATH_TO_FREEMARKER_TUTORIALS/01-hello-world/src/main/webapp"
path="" reloadable="true" />

以上是新建文件hello-world.xml的内容,path自己替换一下

4. You should now be able to access the FreeMarker Hello World webapp at [http://localhost:8080/hello-world/](http://localhost:8080/hello-world/).