For non-form pages (that is, pages that don't need to gather and process user input), I just use a single MultiActionController.
For example, if you have something like:
<a href="home.html">Home</a>
<a href="aboutus.html">About Us</a>
<a href="services.html">Services</a>
<a href="products.html">Products</a>
<a href="directory.html">Employee Directory</a>
...
...
Then, in your Spring servlet config:
Code:
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="home.html">staticPageController</prop>
<prop key="aboutus.html">staticPageController</prop>
<prop key="services.html">staticPageController</prop>
..
</props>
</property>
</bean>
<bean id="staticPageController" class="com.example.StaticPageController">
<!-- maybe inject some property here like a business service object -->
</bean>
Then, your controller should extend MultiActionController and you define as many public ModelAndView() methods as you need.
Code:
public ModelAndView home(HttpServletRequest request, HttpServletResponse response) throws Exception)
{
return new ModelAndView("home");
}
public ModelAndView aboutus(...
public ModelAndView services(...
public ModelAndView products(...
....
You can also use other URL mapping strategies besides SimpleUrlHandlerMapping. The ResourceBundleViewResolver offers good flexibility and localization. In that case, you define your views in a separate properties file. You can use wildcards too to decrease the amount of XML you have to write.