atom feed4 messages in org.apache.struts.userExtra path info and action mappings
FromSent OnAttachments
Tim TrenthamJul 12, 2001 9:11 am 
Ted HustedJul 13, 2001 8:39 am 
Ted HustedJul 13, 2001 10:22 am 
Craig R. McClanahanJul 30, 2001 9:08 pm 
Subject:Extra path info and action mappings
From:Tim Trentham (TTre@hand.com)
Date:Jul 12, 2001 9:11:05 am
List:org.apache.struts.user

I'm trying to use extra path info as a way to pass parameters to my actions. I changed the mapping from the default *.do to something like /execute/*. This works fine except that if I add extra information and try to submit, I get a 400 error telling me that I have submitted an invalid path.

For example, I had a mapping called show.do which has now been changed to /execute/show. Now, if I try to submit /execute/show/user, expecting to have "user" passed to the show servlet as part of the extra path info accessed by request.getPathInfo(), I get the invalid path error. It works if I add another action mapping in the struts-config.xml that looks like this

<action path="/show/user" type="com.mypackage.ShowAction"> <forward name="/show/user" path="/WEB-INF/jsp/user.jsp"/> </action>

This means that I have to have a separate action mapping for each different thing that I'd like an action to perform even though they're using the same action.

I was expecting to be able to have something like this in the struts-config.xml:

<action path="/show" type="com.mypackage.ShowAction"> <forward name="/show/user" path="/WEB-INF/jsp/user.jsp"/> <forward name="/show/group" path="/WEB-INF/jsp/group.jsp"/> </action>

Instead, I have to do this:

<action path="/show/user" type="com.mypackage.ShowAction"> <forward name="/show/user" path="/WEB-INF/jsp/user.jsp"/> </action>

<action path="/show/group" type="com.mypackage.ShowAction"> <forward name="/show/group" path="/WEB-INF/jsp/group.jsp"/> </action>

The idea behind this is that I can have one action that basically just passes through the extra path info and forwards to the correct page based on that info.

Is there another way to set this up so that you don't have to have an action mapping that matches the extra path info?

Thanks.

Tim