struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zarar Siddiqi <zar...@gmail.com>
Subject Re: [S2] Action with wildcard not found and strange behavior of s:form
Date Sun, 24 Jun 2007 19:09:51 GMT

The only mysterious part here is figuring out why you would want to use ! in
your action name.  The default behavior of Struts 2 is for the URL
http://localhost:8080/actionName!myMethod.action to actually execute
myMethod instead of execute() when the action is called so you don't need to
make your struts.xml that complicated.  

Having it like this:

<action name="Authentification"
class="com.authentification.AuthentificationAction">
	<result>/jsp/login.jsp</result>
</action>

and calling 

Authentification!myMethod.action

is good enough.

Zarar



Cyril Gambis wrote:
> 
> Hi everybody!
> 
> I have a strange behavior while using Struts 2, s:form, and action with
> wildcard. Can you please help me?
> 
> Here is my struts.xml file, with a wildcard mapping, very straightforward:
> 
> <action name="Authentification!*" method="{1}"
> class="com.authentification.AuthentificationAction">
> 	<result>/jsp/login.jsp</result>
> </action>
> 
> When I go to http://localhost:8080/Authentification.action, I got a "no
> action found" error.
> 
> 
> If I change struts.xml file like:
> <action name="Authentification"
> class="com.authentification.AuthentificationAction">
> 	<result>/jsp/login.jsp</result>
> </action>
> 
> (I removed the wildcard mapping)
> everything goes fine, the action is found.
> 
> It's surprising since I have another action with a wildcard:
> 
> <action name="Banner!*" method="{1}" class="banner.BannerAction">
> 	<result>/bannersAdministration.jsp</result>
> </action>
> 
> and it works fine!
> 
> 
> And here is the mysterious part:
> when I have the struts xml version without the wildcard mapping, like:
> <action name="Authentification"
> class="com.authentification.AuthentificationAction">
> 	<result>/jsp/login.jsp</result>
> </action>
> 
> and if I have the following in my jsp:
> <s:form action="Authentification!displayQuestion" id="displayQuestionForm"
> >
> 	<s:hidden id="aliasFieldForQuestionForm" name="alias" value=""/>
> </s:form>
> 
> everything work perfectly! It calls the action, and the displayQuestion
> method (not the execute method), as if I put a wildcard mapping for this
> action (but I did not, since the action is not found when I put one).
> 
> Isn't all of this very strange?
> 
> My action is:
> 
> public class AuthentificationAction extends ActionSupport {
> 
> 	private AuthentificationService loginService = new
> AuthentificationServiceWebServiceImpl();
> 
> 	private String alias = "";
> 	private String question = "";
> 	
> 	public String execute() {
> 		return display();
> 	}
> 	public String display() {
> 		return SUCCESS;
> 	}
> 	public String displayQuestion() {
> 		
> 		question = loginService.getQuestion(alias);
> 		
> 		return display();
> 	}
> 	public String getAlias() {
> 		return alias;
> 	}
> 	public void setAlias(String alias) {
> 		this.alias = alias;
> 	}
> 	public String getQuestion() {
> 		return question;
> 	}
> 	public void setQuestion(String question) {
> 		this.question = question;
> 	}
> }
> 
> Do you have an idea about that?
> 
> Thanks!
> Cyril
> 

-- 
View this message in context: http://www.nabble.com/-S2--Action-with-wildcard-not-found-and-strange-behavior-of-s%3Aform-tf3964495.html#a11277516
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


Mime
View raw message