Question

I'm using DynamicMappingFilter and annotated URLs for all my actions.

I'm trying to map "/" to an existing actionBean. The actionbean I want "/" to go to, is currently bound to "/categories".

I found two ways, but I'm wondering if there is a better way in terms of performance.

I created a new IndexActionBean with @UrlBinding("/") at the top.

Inside of it, I can return a ForwardResolution to the Categories class, or I can copy paste the category class code in it, since mine is very simple.

@UrlBinding("/")
public class IndexActionBean  extends AbstractActionBean {
  @DefaultHandler
  public ForwardResolution view() {
    return new ForwardResolution(ShowCategoryActionBean.class);
  }
}

It works, but I don't like having the overhead of the ForwardResolution, especially since this is the root page of the domain and will get a lot of pageviews.

I've tried to use the welcome file, but it doesn't work with DynamicMappingFilter. It's working with DispatcherServlet, such as category.action, but even then, I had problems, and only / was working, and /category and all other urls stopped working and giving 404 not found.

   <welcome-file-list>
    <welcome-file>category.action</welcome-file>
  </welcome-file-list>

Any better ways? I cannot just rename @UrlBinding of /categories to / because I still need /categories, but I want / to forward to it as well.

Was it helpful?

Solution

In your IndexActionBean extend CategoriesBean rather than AbstractActionBean that is:

@UrlBinding("/")
public class IndexActionBean  extends CategoriesBean {
}

So that you can have two url's mapped to same action bean.

OTHER TIPS

Use /index.jsp to forward to your action.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top