You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by emre akbas <em...@gmail.com> on 2005/09/26 09:24:22 UTC

Re: user Digest 25 Sep 2005 21:39:29 -0000 Issue 6130

Thank you Laurie. That is exactly what I am looking for. I had looked at the
documentation on wildcard mappings but I couldn't notice the ** mapping.
Thank you again.

Now, I have another problem. We have written our Struts application using
prefix mappings, i.e "*.do". In order to use DownloadAction with ** mapping,
we should migrate to suffix mapping, i.e. "/do/*" . Is there an easy way of
migrating a whole Struts application from prefix mapping to suffix mapping?
Or, is it possible that both mappings exists in web.xml ? (Sorry, if these
are weird questions.)

From: Laurie Harper <la...@holoweb.net>
> To: user@struts.apache.org
> Date: Sat, 24 Sep 2005 16:38:12 -0400
> Subject: Re: Struts action servlet mapping, getPathInfo() returns null
> Did you look at the documentation on wildcard mappings yet? If you use
> /do/admin/** it'll match arbitrarily 'deep' URLs.
>
> L.
>
> emre akbas wrote:
> > Thank you Dave. I'm afraid predefined mapping schemes like
> /do/admin/*/*"
> > and "/do/admin/*/*/* won't work for me since I want to implement a
> generic
> > file server. I cannot know the length of the URL nor its number of
> tokens
> > separated with "/". Actually, I have written such a fileserver using
> plain
> > old servlets. Since I don't want to mix servlets and Struts actions in
> my
> > Struts application, I'm looking for a way to implement this fileserver
> with
> > a DownloadAction class. But it seems to me that even if I use suffix
> > mapping, there is no way of getting the rest of the URL after the
> action's
> > name, in a generic manner.
> >
> > ---------- Forwarded message ----------
> >
> >>From: Dave Newton <ne...@pingsite.com>
> >>To: Struts Users Mailing List <us...@struts.apache.org>
> >>Date: Fri, 23 Sep 2005 17:53:56 -0400
> >>Subject: Re: user Digest 23 Sep 2005 19:04:19 -0000 Issue 6127
> >>emre akbas wrote:
> >>
> >>
> >>>Dave, of course I know the URL is avaliable from HttpServletRequest. I
> >>
> >>think
> >>
> >>>you didn't read my previous e-mails on the topic.
> >>>
> >>>I couldn't find a way to get the remaining part of the URL after the
> >>>action's name. That is, to get /chapter1/1.html in
> >>>http://localhost:8080/action.do/chapter1/1.html
> >>>
> >>>request.getPathInfo() always returns null.
> >>>
> >>>
> >>
> >>I'm actually a little surprised your Action is firing at all if you're
> >>doing *.do mapping and passing in something that doesn't end with *.do.
> >>
> >>If you use /do/* mapping and pass in something that isn't "actively"
> >>being mapped (i.e., mapping from "/do/chapter1/1.html" to an Action) I'm
> >>not sure I'd expect Struts to handle this.
> >>
> >>Now, if you do something like a wildcard mapping and define how you want
> >>that to work (i.e., mapping from "/do/download/*/*" to an Action) you'll
> >>probably get further--I'd look in to that.
> >>
> >>For instance, I created a generic CRUD action class that mapped
> >>"/do/admin/*/*" and "/do/admin/*/*/*" and stripped out chunks to get
> >>table names, commands, and ids.
> >>
> >>Also check out ActionMapping.getPath():
> >>
> >>"Return context-relative path of the submitted request, starting with a
> >>slash ("/") character, and omitting any filename extension if extension
> >>mapping is being used."
> >>
> >>Dave
> >>
> >>
> >>
> >>
>

Re: user Digest 25 Sep 2005 21:39:29 -0000 Issue 6130

Posted by Laurie Harper <la...@holoweb.net>.
emre akbas wrote:
> Now, I have another problem. We have written our Struts application using
> prefix mappings, i.e "*.do". In order to use DownloadAction with ** mapping,
> we should migrate to suffix mapping, i.e. "/do/*" . Is there an easy way of
> migrating a whole Struts application from prefix mapping to suffix mapping?
> Or, is it possible that both mappings exists in web.xml ? (Sorry, if these
> are weird questions.)

[Note: '*.do' is a suffix, /do/* is a prefix (pre- -> previous); just to 
reduce any confusion for people following along ;-)]

Actually, I think wildcard mappings *should* work with suffix mapping 
too, though I've never tried it. But you can define both types of 
mapping in web.xml, so long as you pick a prefix your application 
doesn't already use. In other words, as long as you don't already have 
linkes that start /do/... then adding a /do/* mapping is fine.

Migrating your whole app from one mapping style to the other wouldn't be 
super hard -- just find anywhere you have an explicit .do and update 
appropriately. However, I wouldn't recommend trying that if this is the 
only driver. If what you have works, keep it ;-)

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org