I am working through Fred Daoud's Stripes book and trying to convert the Hello World application to use friendly URLs, as I'm not a big fan of suffix-based mappings like http://localhost:8080/getting_started/Hello.action.
Here is the before ...
index.jsp:
<jsp:forward page="/Hello.action"/>
web.xml:
<servlet-mapping>
<servlet-name>DispatcherServlet</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
and I have no UrlBinding on my HelloActionBean. I have the book example working.
I'm wondering if the book examples may suit an earlier version of Stripes, as I've downloaded 1.5.1 and my web.xml defines the StripesFilter and StripesDispatcher whereas I've seen a DynamicMappingFilter used elsewhere, e.g. in this article by Fred on TheServerSide.
Anyway, I made the following changes:
index.jsp:
<jsp:forward page="/hello"/>
web.xml:
<servlet-mapping>
<servlet-name>DispatcherServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
HelloActionBean.java:
**@UrlBinding("/hello")**
public class HelloActionBean implements ActionBean
{
However, when I try to load the app through http://localhost:8080/getting_started I see this:
net.sourceforge.stripes.exception.ActionBeanNotFoundException: Could not locate an ActionBean that is bound to the URL [/]. Commons reasons for this include mis-matched URLs and forgetting to implement ActionBean in your class. Registered ActionBeans are: {/hello=class stripesbook.action.HelloActionBean, /controller/DefaultView.action=class net.sourceforge.stripes.controller.DefaultViewActionBean, /hello/=class stripesbook.action.HelloActionBean, /controller/DefaultView.action/=class net.sourceforge.stripes.controller.DefaultViewActionBean}
at net.sourceforge.stripes.controller.AnnotatedClassActionResolver.getActionBean(AnnotatedClassActionResolver.java:341)
and if I access it through http://localhost:8080/getting_started/hello the server seems to go into a loop throwing one exception after another.
Any suggestions appreciated - thanks.
It didn't work for me to just replace the Dispatcher servlet with the DynamicMappingFilter (I got an error message about the DynamicMappingFilter only works in conjunction with the StripesFilter). So I have two filters and one filter-mapping configured in my web.xml now:
I've been trying out a few other things and got it working ...
I removed the existing DispatcherServlet servlet and servlet-mapping definitions in web.xml and replaced with the DynamicMappingFilter.
As a bonus, to change the way link events are passed, so that e.g.
becomes
change the UrlBinding on the ActionBean to: