Tuesday, June 16, 2015

AngularJS, Spring MVC, Tuckey URL Rewrite

I wanted to use html5Mode with an existing Spring MVC backend. This assumes that the front-end code will be deployed as part of the WAR file.
I did the following steps:

1. In Angular, I added the following html5Mode config:


2. In Spring MVC, I added the Tuckey URL Rewrite Module in the Maven pom.xml:


3. Do a Maven Update 4. Open the web.xml and enter the following within the web-app tag (I left the debug line there)



5. Create a urlrewrite.xml under the WEB-INF folder of the your Spring project and the contents should look like the following:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"


Configuration file for UrlRewriteFilter




And that is it! I had trouble before cause I was using 'index.html' in the 'to' tag instead of '/index.html'