Tim Burns' Personal Weblog Flavored with Math, Java, and Oracle
 
Saturday, August 7, 2004 [*]
 

The Spring Thread

Not much time for blogging these days. Sunny days in the 70s. Low humidity. Mountain bike trails are dry and worn hard. First time in a week I've found the time to blog. The Pinkie is taking a long nap and I just read excerpt from a new book on Spring on The Server Side, so I made enough progress on my New Book, New Directions theme to blog about it.

Spring has a multiple-view concept built into the framework. I defined a simple web page called login.htm virtually and never created an actual page. I created a mapping to the controller in your servlet definition file like so:

      <bean id="urlMapping" 
        class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="interceptors">
          <list>
            <ref local="localeChangeInterceptor"/>
            <ref local="themeChangeInterceptor"/>
            <ref local="copyInterceptor"/>
          </list>
        </property>
        <property name="mappings">
          <props>
            <prop key="/login.htm">myAppController</prop>
    			</props>
        </property>
      </bean>
    
Since I plan to have a single controller control all my apps, I specified the method to call within the controller to handle the login.
      <bean id="myAppMethodNameResolver"  
     
    class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
        <property name="mappings">
          <props>
            <prop key="/login.htm">handleLogin</prop>
          </props>
        </property>
      </bean>
    
Now I had to add within my MyAppController.java the method to handle the login action. I then specified the view template in views-myapp.properties with the following configuration.
    loginView.attributesCSV=htitle=[login.htitle],nav=[nav.jsp],content=[login.jsp]
    
Now when I call http://localhost/myapp/login.htm, I get a login page using a shared template with all special form content defined in login.jsp. The funny thing is that nowhere did I ever write a page called login.htm even though that was the URL.

 
Comments [0]
 
xml    Blogroll Me!

Personal

Waterfire Date

Being a Father Changes Everything

Daddy's in Charge

Rhode Island is Famous For You

Discovering My Own Backyard

Autumn lingers in New England

 

Java

Diving into Spring
Regular Expressions and Unit Tests
Tracking Errors with JavaMail
Really Simple Tomcat, Really
J2EE with Free Software
 

Numerical

The SVD, Benchmarking and Optimization
Fun with Optimization
 

Perl

New Computer and Perl CTime
 

Nature

The Hawk in the Garden

The Morning Run

Coprinus Plicatilis

Morning of the Wolf

 

The Daily Chronic

 

Currently Reading

 

References

BioInformatics

BioTech

Epicurious

Statistics

 

Archive

2004
 September 02 09
 August 07 11 15 29
 July 04 07 09 14 15 18 19 20 21 22 24 25 30
 June 02 05 09 17 21 24 28
 May 05 06 10 11 12 15 20 24 25 28 29
 April 01 04 07 09 11 16 17 18 20 22 24 25 27 29
 March 02 15 21 22 24 27
 February 13
 January 04 16 19 29
2003
 December 06 12
 November 02 23 29
 October 07 11 12 16 18 21 24 26
 September 04 09 10 12 14 28
 August 05 08 13 17 18 25 29
 July
 June
2002
2001
 

Photos

Morning of the Wolf
Phantom Farms
Providence
Baby Shower
Camden, Maine
 

Resume

 

Wiki

Creative Commons License
This work is licensed under a Creative Commons License