struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Illes, Szabolcs" <S.Il...@nature.com>
Subject Parameters after the action name, annotation based config not working
Date Wed, 02 Dec 2009 09:59:02 GMT
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   
********************************************************************************

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message