You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Graham Leggett <mi...@sharp.fm> on 2009/11/01 15:38:46 UTC

strust2: filter-mapping best practice - /*

Hi all,

I am trying to develop a struts2 app, and I am struggling to find a
reference that explains the thinking and/or best practice behind the
url-pattern in web.xml.

Google uncovers hundreds of articles showing the url-pattern being
specified as follows:

	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

This has the side effect that every URL in the application passes
through struts2 - is this intentional?

What I am trying to achieve is to include a directory of images within
my war file, and none of the images display, because struts2 grabs the
URLs and processes the request instead.

What is the recommended best practice for embedding images within a web
application, so that the images are displayed without being fiddled with
by struts2?

Regards,
Graham
--

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


Re: strust2: filter-mapping best practice - /*

Posted by José Santos <sa...@gmail.com>.
hi,

you can always use extensionless actions, as long as they're under some
directory. example:

<filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/action/*</url-pattern>
    </filter-mapping>

    <filter-mapping> <!-- needed by struts -->
        <filter-name>struts2</filter-name>
        <url-pattern>/struts/*</url-pattern>
    </filter-mapping>

in the case, static content (HTML, CSS, JS, etc.) located outside /action is
served directly by the web server/jsp container and not processed by Struts2
(it could even be moved out of the web server/jsp container).

santos.

On Mon, Nov 2, 2009 at 5:08 PM, James Cook <Ja...@wecomm.com> wrote:

> Yes, this is what I do also, I have an app with a webservice so needed
> it to not get caught in the Struts filter. It is a shame however, as I
> would like to have kept the URLs neat without the action on the end. But
> as they say, don't get caught up in what the URL says.
>
> -----Original Message-----
> From: Greg Lindholm [mailto:greg.lindholm@gmail.com]
> Sent: 02 November 2009 15:53
> To: Struts Users Mailing List
> Subject: Re: strust2: filter-mapping best practice -
> <url-pattern>/*</url-pattern>
>
> I have a number of servlets in the same web app so to make it work I
> have
> restrict the filter mapping  as follows.
>
>    <filter-mapping>
>        <filter-name>struts2</filter-name>
>        <url-pattern>*.action</url-pattern>
>    </filter-mapping>
>
>    <filter-mapping>
>        <filter-name>struts2</filter-name>
>        <url-pattern>/struts/*</url-pattern>
>    </filter-mapping>
>
> The first one catches all requests with .action extensions which is what
> I
> use.
>
> The second one was suggested on this mailing list since there are
> resources
> that struts UI controls can request.
>
> On Sun, Nov 1, 2009 at 9:38 AM, Graham Leggett <mi...@sharp.fm> wrote:
>
> > Hi all,
> >
> > I am trying to develop a struts2 app, and I am struggling to find a
> > reference that explains the thinking and/or best practice behind the
> > url-pattern in web.xml.
> >
> > Google uncovers hundreds of articles showing the url-pattern being
> > specified as follows:
> >
> >        <filter-mapping>
> >                <filter-name>struts2</filter-name>
> >                <url-pattern>/*</url-pattern>
> >        </filter-mapping>
> >
> > This has the side effect that every URL in the application passes
> > through struts2 - is this intentional?
> >
> > What I am trying to achieve is to include a directory of images within
> > my war file, and none of the images display, because struts2 grabs the
> > URLs and processes the request instead.
> >
> > What is the recommended best practice for embedding images within a
> web
> > application, so that the images are displayed without being fiddled
> with
> > by struts2?
> >
> > Regards,
> > Graham
> > --
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

RE: strust2: filter-mapping best practice - /*

Posted by James Cook <Ja...@wecomm.com>.
Yes, this is what I do also, I have an app with a webservice so needed
it to not get caught in the Struts filter. It is a shame however, as I
would like to have kept the URLs neat without the action on the end. But
as they say, don't get caught up in what the URL says.

-----Original Message-----
From: Greg Lindholm [mailto:greg.lindholm@gmail.com] 
Sent: 02 November 2009 15:53
To: Struts Users Mailing List
Subject: Re: strust2: filter-mapping best practice -
<url-pattern>/*</url-pattern>

I have a number of servlets in the same web app so to make it work I
have
restrict the filter mapping  as follows.

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>*.action</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/struts/*</url-pattern>
    </filter-mapping>

The first one catches all requests with .action extensions which is what
I
use.

The second one was suggested on this mailing list since there are
resources
that struts UI controls can request.

On Sun, Nov 1, 2009 at 9:38 AM, Graham Leggett <mi...@sharp.fm> wrote:

> Hi all,
>
> I am trying to develop a struts2 app, and I am struggling to find a
> reference that explains the thinking and/or best practice behind the
> url-pattern in web.xml.
>
> Google uncovers hundreds of articles showing the url-pattern being
> specified as follows:
>
>        <filter-mapping>
>                <filter-name>struts2</filter-name>
>                <url-pattern>/*</url-pattern>
>        </filter-mapping>
>
> This has the side effect that every URL in the application passes
> through struts2 - is this intentional?
>
> What I am trying to achieve is to include a directory of images within
> my war file, and none of the images display, because struts2 grabs the
> URLs and processes the request instead.
>
> What is the recommended best practice for embedding images within a
web
> application, so that the images are displayed without being fiddled
with
> by struts2?
>
> Regards,
> Graham
> --
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: strust2: filter-mapping best practice - /*

Posted by Greg Lindholm <gr...@gmail.com>.
I have a number of servlets in the same web app so to make it work I have
restrict the filter mapping  as follows.

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>*.action</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/struts/*</url-pattern>
    </filter-mapping>

The first one catches all requests with .action extensions which is what I
use.

The second one was suggested on this mailing list since there are resources
that struts UI controls can request.

On Sun, Nov 1, 2009 at 9:38 AM, Graham Leggett <mi...@sharp.fm> wrote:

> Hi all,
>
> I am trying to develop a struts2 app, and I am struggling to find a
> reference that explains the thinking and/or best practice behind the
> url-pattern in web.xml.
>
> Google uncovers hundreds of articles showing the url-pattern being
> specified as follows:
>
>        <filter-mapping>
>                <filter-name>struts2</filter-name>
>                <url-pattern>/*</url-pattern>
>        </filter-mapping>
>
> This has the side effect that every URL in the application passes
> through struts2 - is this intentional?
>
> What I am trying to achieve is to include a directory of images within
> my war file, and none of the images display, because struts2 grabs the
> URLs and processes the request instead.
>
> What is the recommended best practice for embedding images within a web
> application, so that the images are displayed without being fiddled with
> by struts2?
>
> Regards,
> Graham
> --
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>