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-tp21645204p21645204.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to