You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Musachy Barroso <mu...@gmail.com> on 2009/12/03 23:04:58 UTC

Re: Parameters after the action name, annotation based config not working

Unfortunately wild card doesn't work really well with convention in
2.1.8. You would have to use trunk. If you use trunk, you could use
the advanced wild cards, which are more flexible, and easier to
use(they were written for that exact use case):

http://struts.apache.org/2.x/docs/wildcard-mappings.html (bottom)

musachy



On Thu, Dec 3, 2009 at 8:45 AM, Illes, Szabolcs <S....@nature.com> wrote:
> Hi All,
>
>
>
> I'd like to report a possible bug in struts2 annotation based action
> mapping:
>
>
>
> I wanted to have slashes in my action names and use them as parameters
> (REST style service)
>
>
>
> For example:
>
>
>
> The action name is /opds/0028-0838/2009 and is mapped to EPubOPDSAction
>
>
>
> The problem is that it only works when I use the struts2.xml to setup
> map the action:
>
>
>
> struts.xml:
>
>
>
> <struts>
>
>  <constant name="struts.enable.SlashesInActionNames" value="true"/>
>
>  <constant name="struts.mapper.alwaysSelectFullNamespace"
> value="false"/>
>
>  <constant name="struts.objectFactory" value="guice"/>
>
>
>
>  <package name="rest" extends="struts-default" namespace="/epub/rest">
>
>
>
>    <action name="opds/*/*"
> class="com.nature.mobile.epub.actions.EPubOPDSAction">
>
>      <param name="issn">{1}</param>
>
>      <param name="year">{2}</param>
>
>     <result>/WEB-INF/content/epub/rest/opds.jsp</result>
>
>     </action>
>
>    </package>
>
> </struts>
>
>
>
> Action class: ( nothing special)
>
> public class EPubOPDSAction extends ActionSupport implements
> ServletRequestAware {
>
>    public String execute() throws Exception { ... }
>
>
>
>   public void setYear(String year) { }  // gets called with year
>
>
>
>    public void setIssn(String issn) {  } // gets called with issn
>
> }
>
>
>
> but not when using java annotations:
>
>
>
> struts.xml:
>
> <struts>
>
>  <constant name="struts.enable.SlashesInActionNames" value="true"/>
>
>  <constant name="struts.mapper.alwaysSelectFullNamespace"
> value="false"/>
>
>  <constant name="struts.objectFactory" value="guice"/>
>
> </struts>
>
>
>
> @Namespace("/epub/rest")
>
> @Result(name="success", location="/WEB-INF/content/epub/rest/opds.jsp")
>
> public class EPubOPDSAction extends ActionSupport implements
> ServletRequestAware {
>
>
>
> @Override
>
> @Action(value="opds/*/*",
>
>            params={"issn","{1}", "year", "{2}"})
>
>    public String execute() throws Exception { ... }
>
>
>
>   public void setYear(String year) { }
>
>
>
>    public void setIssn(String issn) {  }
>
>
>
> }
>
>
>
>
>
> This one just throws an exception that there is no action mapped for
> /opds/0028-0838/2009
>
>
>
> I'm using:
>
> struts2-core 2.1.8.1
>
> and
>
> struts2-convention-plugin
>
> 2.1.8.1
>
>
>
> Any idea?
>
>
>
> Thanks,
>
> Szabolcs
>
>
>
>
> ********************************************************************************
> DISCLAIMER: This e-mail is confidential and should not be used by anyone who is
> not the original intended recipient. If you have received this e-mail in error
> please inform the sender and delete it from your mailbox or any other storage
> mechanism. Neither Macmillan Publishers Limited nor any of its agents accept
> liability for any statements made which are clearly the sender's own and not
> expressly made on behalf of Macmillan Publishers Limited or one of its agents.
> Please note that neither Macmillan Publishers Limited nor any of its agents
> accept any responsibility for viruses that may be contained in this e-mail or
> its attachments and it is your responsibility to scan the e-mail and
> attachments (if any). No contracts may be concluded on behalf of Macmillan
> Publishers Limited or its agents by means of e-mail communication. Macmillan
> Publishers Limited Registered in England and Wales with registered number 785998
> Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS
> ********************************************************************************
>

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