Return-Path: X-Original-To: apmail-struts-user-archive@www.apache.org Delivered-To: apmail-struts-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 90CEBDBEC for ; Mon, 10 Dec 2012 19:40:12 +0000 (UTC) Received: (qmail 15042 invoked by uid 500); 10 Dec 2012 19:40:10 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 15016 invoked by uid 500); 10 Dec 2012 19:40:10 -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 15007 invoked by uid 99); 10 Dec 2012 19:40:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Dec 2012 19:40:10 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [74.125.82.44] (HELO mail-wg0-f44.google.com) (74.125.82.44) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Dec 2012 19:40:03 +0000 Received: by mail-wg0-f44.google.com with SMTP id dr12so1789852wgb.35 for ; Mon, 10 Dec 2012 11:39:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=kd8i1Egvq5EmZS1X6p8pi6oShKQxmHkyi+5nwMfnE1U=; b=ZvOnojsa+Pg6S0xZSezy4L9lAqHwxYNMfhQ0Bb642dZG7D/Knf3vFicuee8Bc2h3sz wKZjQsM3+T1DWPJoMkUD5eFFKj2m+pVjAOdpmulyLETwZNTs6UFABgv7/2kkc7Jc5DmZ IBpJ6WEEgni2FuepmvI/frbD7J0v/QUGtC8WX84FCNL/q7SVEqK4ceQz/oCP9PJxiOA2 FYBXHR4K1vq+iOZNbauQJxewFVTDQQis2wRTfucgYz1hqWsYgRBanVhY9/WD3uSQyaOq XucgTwHgmLpk8fNaK6WYoIHKWYVAB3Qk4F52/AO1JiAVqWpDAf0UcALtCkdPHZiqo25b 1uBA== MIME-Version: 1.0 Received: by 10.180.81.232 with SMTP id d8mr12749984wiy.14.1355168381817; Mon, 10 Dec 2012 11:39:41 -0800 (PST) Received: by 10.216.185.19 with HTTP; Mon, 10 Dec 2012 11:39:41 -0800 (PST) In-Reply-To: References: Date: Mon, 10 Dec 2012 19:39:41 +0000 Message-ID: Subject: Re: REST Mappers From: Antonios Gkogkakis To: Struts Users Mailing List Content-Type: multipart/alternative; boundary=f46d044401c202530804d084bada X-Gm-Message-State: ALoCoQmI/SGTRb/Nl8CwHJua7Nq6X1MPcIxe8XzUrWxpYTSjf5ygbglKn1eLrWp3x5GJZhX1Ffs7 X-Virus-Checked: Checked by ClamAV on apache.org --f46d044401c202530804d084bada Content-Type: text/plain; charset=ISO-8859-1 > What would be the best way to share an example? Send it here on the list? >You can register an issue and add text and example there or send it here Since this is my first contribution I'll post it here :). I based my example on https://cwiki.apache.org/confluence/display/WW/RestfulActionMapper so it makes sense for someone viewing the wiki Furthermore, I tested it struts 2.3.1.2 and I also have a similar working example in production. To use the Restful2ActionMapper in an existing struts application we have to change the strus.mapper.class constant and let it point to the Restful2ActionMapper The problem with the above approach is that we may break existing actions because the Restful2ActionMapper tries to guess the method name using conventions that aren't applicable to normal action classes. To overcome the above problem, we have to use a different action mapper depending on the url we want to process. REST actions will be processed by the Restful2ActionMapper and non-REST actions by the DefaultActionMapper To achieve that we have to rely on nampespaces and the PrefixBasedActionMapper that can choose which action mapper to use for a particular url based on a prefix (the action namespace). To put everything together, we create a package for our rest actions ....interceptor config {0} ....results .... All other actions remain in their existing packages and namespaces we use the PrefixBasedActionMapper telling it to use the Restful2ActionMapper for actions in the /rest namespace and the DefaultActionMapper for all other actions For the Restful2ActionMapper to work we also have to set @Chad 1) I think you are looking at the issue of failing to guess the method using Rest conventions for non-REST actions but in the context of the ActionMapper used in the REST plugin I don't know if something similar can be applied to the RestFul2ActionMapper, I just documented how we used the Restful2ActionMapper 2) I've read your book, when I started working with struts2. Nice work indeed ! Regards, Antonios > > --f46d044401c202530804d084bada--