You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Filipe David Manana <fd...@ieee.org> on 2008/02/19 10:09:07 UTC

Re: Struts2 actions' extension

I managed to find a solution to be able to use extensionless actions.
Just subclass the DefaultActionMapper like this:

package org.apache.struts2.dispatcher.mapper;
>
> import java.util.*;
>
> public class LsfwebMapper extends DefaultActionMapper
> {
>    private static List<String> ignoredExtensions = new
> ArrayList<String>();
>
>    static
>    {
>       ignoredExtensions.add(".jsp");
>       ignoredExtensions.add(".css");
>       ignoredExtensions.add(".js");
>       ignoredExtensions.add(".gif");
>       ignoredExtensions.add(".png");
>       ignoredExtensions.add(".html");
>    }
>
>
>    String dropExtension(String name)
>    {
>       Iterator<String> it = ignoredExtensions.iterator();
>
>       while ( it.hasNext() )
>       {
>          if ( name.endsWith(it.next()) )
>             return null;
>       }
>
>       return super.dropExtension(name);
>    }
> }
>
>
Don't forget to place this class in a directory named
org/apache/struts2/dispatcher/mapper/  within your source directory,
src/main/java/ (if using maven).


On Sat, Jan 12, 2008 at 6:28 PM, Filipe David Manana <fd...@ieee.org>
wrote:

> Hi,
>
> I have set the property struts.action.extension to the empty string. I can
> now invoke my actions with the default ".action" suffix, although I have a
> problem:
>
> css files (ending in .css) and javascript (.js) are no longer accessible
> to the client.
>
> How can I fix this?
>
> cheers
>
> --
> Filipe David Manana,
> fdmanana@ieee.org
>
> Obvious facts are like secrets to those not trained to see them.




-- 
Filipe David Manana,
fdmanana@ieee.org

Obvious facts are like secrets to those not trained to see them.

Re: Struts2 actions' extension

Posted by Filipe David Manana <fd...@ieee.org>.
And, set it in the struts.properties file as the ActionMapper:

struts.mapper.class=org.apache.struts2.dispatcher.mapper.LsfwebMapper


On Feb 19, 2008 10:09 AM, Filipe David Manana <fd...@ieee.org> wrote:

> I managed to find a solution to be able to use extensionless actions.
> Just subclass the DefaultActionMapper like this:
>
> package org.apache.struts2.dispatcher.mapper;
> >
> > import java.util.*;
> >
> > public class LsfwebMapper extends DefaultActionMapper
> > {
> >    private static List<String> ignoredExtensions = new
> > ArrayList<String>();
> >
> >    static
> >    {
> >       ignoredExtensions.add(".jsp");
> >       ignoredExtensions.add(".css");
> >       ignoredExtensions.add(".js");
> >       ignoredExtensions.add(".gif");
> >       ignoredExtensions.add(".png");
> >       ignoredExtensions.add(".html");
> >    }
> >
> >
> >    String dropExtension(String name)
> >    {
> >       Iterator<String> it = ignoredExtensions.iterator();
> >
> >       while ( it.hasNext() )
> >       {
> >          if ( name.endsWith(it.next()) )
> >             return null;
> >       }
> >
> >       return super.dropExtension(name);
> >    }
> > }
> >
> >
> Don't forget to place this class in a directory named
> org/apache/struts2/dispatcher/mapper/  within your source directory,
> src/main/java/ (if using maven).
>
>
>
> On Sat, Jan 12, 2008 at 6:28 PM, Filipe David Manana <fd...@ieee.org>
> wrote:
>
> > Hi,
> >
> > I have set the property struts.action.extension to the empty string. I
> > can now invoke my actions with the default ".action" suffix, although I have
> > a problem:
> >
> > css files (ending in .css) and javascript (.js) are no longer accessible
> > to the client.
> >
> > How can I fix this?
> >
> > cheers
> >
> > --
> > Filipe David Manana,
> > fdmanana@ieee.org
> >
> > Obvious facts are like secrets to those not trained to see them.
>
>
>
>
> --
> Filipe David Manana,
> fdmanana@ieee.org
>
> Obvious facts are like secrets to those not trained to see them.
>



-- 
Filipe David Manana,
fdmanana@ieee.org

Obvious facts are like secrets to those not trained to see them.