Spring Batch Admin - Home Menu Breaks When Using A ServletMapping
I'm trying to find a way around this issue at this point and think it should be fixed in the next release.
Currently the HomeMenu registers itself with the URL "" as seen below:
Code:
public HomeMenu() {
super("", "Home", Integer.MIN_VALUE);
}
This works fine if you are mapping the dispatcher servlet to root "/"; however, if you follow the guidelines for changing the default mapping (to lets say "/batch") which involves updating the web.xml servlet-mapping
Code:
<servlet-mapping>
<servlet-name>Batch Servlet</servlet-name>
<url-pattern>/batch/*</url-pattern>
</servlet-mapping>
and then overriding the resourceService
Code:
<bean id="resourceService" class="org.springframework.batch.admin.web.resources.DefaultResourceService">
<property name="servletPath" value="/batch"/>
</bean>
the Home link stops working because the code will concat the prefix and url resulting in "/batch". If I change the servletPath in resource service to "/batch/" the Home link works again but the rest break because you end up with urls like "/batch//jobs".
Long story short, HomeMenu should really pass "/" to BaseMenu or more accurately "/home".
Finally, to my question. Is there an easy way to override the HomeMenu bean to use "/home" instead until the code is updated? It doesn't have an id defined for it in the manager-context.xml so I'm not sure how
Code:
<bean class="org.springframework.batch.admin.web.HomeMenu" parent="baseMenu"/>
<bean class="org.springframework.batch.admin.web.JobsMenu" parent="baseMenu"/>
<bean class="org.springframework.batch.admin.web.ExecutionsMenu" parent="baseMenu"/>
<bean class="org.springframework.batch.admin.web.FilesMenu" parent="baseMenu"/>
I've thought about overriding the menuManager itself and manually grabbing the HomeMenu after its been injected but hate hacks like that. If anyone has another idea, please let me know. Thanks! :)