|
From: Stefan D S. <ste...@us...> - 2004-08-08 15:18:37
|
After trying to build a dynamic breadcrumb (page path), I have ran into a=
n issue where the URL path has to be duplicated in the controller code an=
d therefore causes the maintainance of paths in two places.
For example:
<bean id=3D"urlMapping" class=3D"org.springframework.web.servlet.handler.=
SimpleUrlHandlerMapping">
<property name=3D"interceptors">
<list>
<ref bean=3D"localeChangeInterceptor" />
</list>
</property>
<property name=3D"mappings">
<props>
<prop key=3D"/index.htm">homeController</prop>
<prop key=3D"/secure/main.htm">homeController</prop>
</props>
</property>
</bean>
Since the path is the key (e.g. /secure/main.htm), there is no way to get=
to this path in your controller code when preparing (e.g. a breadcrumb) =
for a dynamic view but to duplicate the path in the controller (or a reso=
urce bundle, another bean etc.). Even in using the mappings property of t=
he SimpleUrlHandleMapping bean, since the paths are the keys, you will ne=
ed to know the path therefore changing the path in the SimpleUrlHandleMap=
ping, will warrant a change in the application code which uses that path =
within a breadcrumb path scenario.
My preferance would be to see that the mappings property in the URL is no=
t keyed off the actual path itself but given a name as done in views.prop=
erties (e.g. main.url) so that this can be used in the application code a=
s a maping to the actual path and therefore the maintenance would only ne=
ed to be done in the SimpleUrlHandleMapping bean definition.
Maybe one way around this is to use XML Entities or something similar. I =
think some discussions around those were going on recently.=
|