views:

102

answers:

1

I'm learning Spring MVC (and servlets in general) and following springsource's mvc-ajax example, which uses annotated controller methods. It appears that there is only one url-pattern (in web.xml) mapped to a servlet in that example:

/app/*

I've deployed the app as a WAR file, and the actual, ugly URL I'm requesting is http://127.0.0.1:8080/org.springframework.samples.mvc.ajax-1.0.0-20100407.233245-1/account.

So, it appears that 'app' in '/app/*' is a variable corresponding to 'org.springframework.samples.mvc.ajax-1.0.0-20100407.233245-1', however, it isn't universal because it isn't usable in my own app, and it contradicts my understanding that url-pattern contains the portion of the URL after the app name. So, what is 'app'? Where is it configured?

A: 

Have a look at the urlrewrite.xml file.

This is where it is defined that all incoming urls (except the ones that start with /styles/, /scripts/, /images/ ) will be rewritten with /app/ at the beginning

<rule>
   <from>/**</from>
   <to>/app/$1</to>
</rule>

So when it reaches the dispatcher servlet, the url is in the form /app/myOriginalPath.

ccheneson