You do not know which Spring variant this question relates to, but in the standard org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandlerthere is a property useReferer, since Spring 3.0.
So, all you have to do is configure it like this, and the output will be redirected to where the user came:
<bean id="logoutSuccessHandler" class="org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler">
<property name="useReferer" value="true"/>
</bean>
<security:http>
<security:logout logout-url="/logout" success-handler-ref="logoutSuccessHandler" />
</security:http>
source
share