Thursday 23 June 2011

Why don't my spring security tags work ?

A good question indeed ... but first the background.

I was working on a quick app, using Struts 2, Spring, Spring Security, and SiteMesh (3 Alpha 2 for those that care - it's actually pretty good for an 'alpha' tag).

Specifically, I hadn't used the Spring Security taglib before, so I couldn't understand why the tags I was specifying just weren't doing anyrhing. It was as if they were being ignored.

It turn's out, after some significant head scrathing, and swearing that I had fallen foul of web.xml filter ordering. You have to have the SiteMesh filter *after* the Spring Security one, as follows:

... other web.xml stuff

 
 
     springSecurityFilterChain
     org.springframework.web.filter.DelegatingFilterProxy
 
 
 
     springSecurityFilterChain
     /*
 


 
 
         sitemesh
         org.sitemesh.config.ConfigurableSiteMeshFilter
 

 
   
         sitemesh
         /*
   

... other web.xml stuff

If you put them in the order above, ev erything works swimmingly, and the tags are honoured.

Hope that helps.