You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by joea88 <kh...@gmail.com> on 2009/04/02 01:15:02 UTC

Re: ActionMapper doesn't add Parameter

You need to add <interceptor-ref name="actionMappingParams"/> to your
struts.xml.


Stephan Schröder wrote:
> 
> the objectiv is to be able to have url like ".../public/123.mp3" so this
> customized ActionMapper was written.
> 
> public class MyActionMapper extends DefaultActionMapper {
> 
>        static ActionMapper fallback = new DefaultActionMapper();
> 
>        private static String getSongIdFromUrl(String s, String regex){
> 
>                Matcher m = Pattern.compile(regex).matcher(s);
>                return m.find() ? m.group(1) : null;
>        }
> 
>        @Override
>        public ActionMapping getMapping(HttpServletRequest request,
>                        ConfigurationManager configManager) {
>                String uri = getUri(request);
>                String regex = "/public/(\\d+).mp3";
>                String id = getSongIdFromUrl(uri, regex);
>                if(id!=null){
>                        ActionMapping m = new ActionMapping();
>                        m.setExtension("");
>                        m.setMethod("download");
>                        m.setNamespace("/public");
>                        m.setName("fileDownload");
>                        Map params = new TreeMap();
>                        params.put("id", id);
>                        m.setParams(params);
>                        return m;
>                }
>                return fallback.getMapping(request, configManager);
>        }
> }
> 
> the problem is, that the id-Attribute altough correctly extracted from the
> url dosn't become part of the parameter-list. The url
> ".../public/123.mp3?id=123" works by the way but is of course redundant.
> Why doesn't 
> 
> params.put("id", id);
> m.setParams(params);
> 
> work?
> 

-- 
View this message in context: http://www.nabble.com/ActionMapper-doesn%27t-add-Parameter-tp21645204p22835002.html
Sent from the Struts - User mailing list archive at Nabble.com.


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