Just to expand on this a little bit ... The problem is that the Stripes tags
normally generate URLs relative to the server root, which means they include
the app's context path at the beginning. If you were to do, say, <s:link
href="/sfh/blah" /> in an application whose context path is /sfh, we can't
determine if the path you've passed in already includes the context path or
if we're supposed to prefix it. So basically, the logic we use is if the
path already starts with the context root then don't prefix it again. And
when you really want it to do /sfh/sfh/blah, that's when that logic bites
you.

Internally, when you use "beanclass" instead of "href", the tag just looks
up the URL binding for the ActionBean class and then works with that value
just like it would if you had used "href."

-Ben

On Sat, Jan 31, 2009 at 10:13 AM, Laird Nelson <[email protected]> wrote:

> Interesting; thanks for the tips and workarounds.
>
> Best,
> Laird
>
>
> On Fri, Jan 30, 2009 at 7:05 PM, Freddy Daoud <[email protected]> wrote:
>
>> Wow! I clearly remember running across this issue a year ago
>> and writing it in chapter 2 of the Stripes book. Honestly, I didn't
>> think many people would run into this problem. I warned against
>> using the same name for the context path and for the first part
>> of the package that contains your action beans - exactly what
>> you have with "sfh".
>>
>> You have two options. The first one is obvious and probably not
>> what you want: use a different name either for the context path
>> or for the first part of the package.
>>
>> The second option is to put your action beans in a package that
>> contains one of the names that Stripes truncates in its URL
>> binding strategy: "action", "stripes", "web", or "www". For
>> example:
>>
>> 1. sfh.stripes.actionbeans.FoobarActionBean
>> 2. sfh.web.actionbeans.FoobarActionBean
>> 3. sfh.action.FoobarActionBean
>>
>> and so on.
>>
>> That would resolve the conflict because the links would become:
>>
>> 1. http://localhost:8080/sfh/actionbeans/Foobar.action
>> 2. http://localhost:8080/sfh/actionbeans/Foobar.action
>> 3. http://localhost:8080/sfh/Foobar.action
>>
>> because sfh is still the context path, but the path to the
>> action bean does not include the package parts up to and including
>> "action", "stripes", "web", or "www".
>>
>> Hope that helps.
>>
>> Cheers,
>> Freddy
>> http://www.stripesbook.com
>>
>> On Fri, 30 Jan 2009 17:26:43 -0500, "Laird Nelson" <[email protected]>
>> said:
>> > I am using a <stripes:link> tag, specifying its beanclass attribute.
>> >
>> > My war file is named "sfh.war" and is deployed under the servlet context
>> > path of "sfh", so all URLs under it begin, ultimately, with
>> > http://localhost:8080/sfh.  sfh is also the name of my leading package
>> > fragment.
>> >
>> > I specify the beanclass attribute like this:
>> > "sfh.actionbeans.FoobarActionBean".
>> >
>> > I would expect this to ultimately resolve to a link like this:
>> >
>> > http://localhost:8080/sfh/sfh/actionbeans/Foobar.action
>> >
>> > ...but instead it is resolved to:
>> >
>> > http://localhost:8080/sfh/actionbeans/Foobar.action
>> >
>> > Is this a bug or a feature?
>> >
>> > I know I can get around it with an explicit UrlBinding, but was curious
>> > as
>> > to what the default behavior should be here.
>> >
>> > Thanks,
>> > Laird
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by:
>> SourcForge Community
>> SourceForge wants to tell your story.
>> http://p.sf.net/sfu/sf-spreadtheword
>> _______________________________________________
>> Stripes-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to