Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 3856 invoked from network); 15 Aug 2007 11:51:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Aug 2007 11:51:52 -0000 Received: (qmail 68245 invoked by uid 500); 15 Aug 2007 11:51:40 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 68112 invoked by uid 500); 15 Aug 2007 11:51:39 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 68095 invoked by uid 99); 15 Aug 2007 11:51:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Aug 2007 04:51:39 -0700 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Aug 2007 11:51:36 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1ILHP9-00055Q-C1 for user@struts.apache.org; Wed, 15 Aug 2007 04:51:15 -0700 Message-ID: <12160600.post@talk.nabble.com> Date: Wed, 15 Aug 2007 04:51:15 -0700 (PDT) From: rakeshxp To: user@struts.apache.org Subject: Re: Struts 2 URL parameters lost - final status In-Reply-To: <12023713.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: rakeshxp@gmail.com References: <11934381.post@talk.nabble.com> <12023713.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org I am using Struts 2.0.6 and the jar contains struts struts-default.xml which contains the following property We have a struts.xml in WEB-INF/classes folder and I was trying to override the default actionmapper by having the following lines in my struts.xml ( just for testing I am overriding with the default class itself ) But this results in an error when I started up tomcat Unable to load bean: type:org.apache.struts2.dispatcher.mapper.ActionMapper class:org.apache.struts2.dispatcher.mapper.DefaultActionMapper - bean - file:/C:/software/tomcat6/webapps/abc/WEB-INF/classes/struts.xml:17:149 Caused by: Bean type interface org.apache.struts2.dispatcher.mapper.ActionMapper with the name struts has already been loaded by [unknown location] - bean - file:/C:/software/tomcat6/webapps/abc/WEB-INF/classes/struts.xml:17:149 So the question that I have are 1) How do I override the mapping class ? 2) Why are there 4 bean declaration for actionmapper ? thanks in advance! JBL wrote: > > Final answer: we implemented a custom ActionMapper that handles a URL > string that doesn't involve a ? to separate the query parameters. Stuck a > reference to it in struts.properties: > > struts.mapper.class=mypackage.MyActionMapper > > Building a new ActionMapper isn't terribly difficult. It helps to define > your expected URLs with a regular expression, then use a precompiled > pattern. Ours looks something like: > > private static String NAMESPACE_REGEX = "..."; > private static String ACTION_REGEX = "..."; > private static String METHOD_REGEX = "..."; > private static String PARAMS_REGEX = "..."; > > private static String URI_REGEX = (concatenate the four above) > > private static Pattern URI_PATTERN = Pattern.compile(URI_REGEX); > > Then, in getMapping(), pull out the URI (similar to DefaultActionMapper) > and call > > Matcher m = URI_PATTERN.matcher(uri); > > If you get a match, create a new ActionMapping and set its components > based on the matching groups: > > mapping.setNamespace(m.group(1)); > mapping.setName(m.group(1)); > > etc. > > You can parse the parameter section and build a map to pass to > mapping.setParams(). > > Using a precompiled pattern may or may not be the most efficient possible > solution, but it helps you define exactly what URIs you expect. I > recommend throwing a bunch of possibilities at it in your unit test code > with various components present and missing. If you're a little unsure > about regular expressions, build some unit tests for those, too. Sun has a > decent write-up in their Java documentation: > > http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html > > Especially read the "Groups and Capturing" section, it's a handy tool to > have in your portfolio. > > We may yet discover why we couldn't get query parameters, but this works > for now. Good luck. > -- View this message in context: http://www.nabble.com/Struts-2-URL-parameters-lost-tf4196254.html#a12160600 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