1

I am new to jquery and ajax. I want to call a particular method "logout" of action 'LoginAction' in Struts2. I am getting an error

There is no Action mapped for namespace / and action name logoutLoginAction.

My ajax code is:

function signout(){
     $.ajax({   
         type: "POST",
         assync:false,
         url: "logoutLoginAction.action",
         success: function(messageResponse) {                   
         response=messageResponse;
         alert(response);
     }});        
}
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
Raina
  • 45
  • 4

1 Answers1

0

What you are trying to achieve is called Wildcard mapping.

In your case it should be something like:

<action name="/*LoginAction" class="foo.bar.LoginAction" method="{1}">
    <result>{1}.jsp</result>
</action>

If you will call logoutLoginAction, logout will be used as {1} and then the logout() method will be called and the logout.jsp file will be returned.

Alternatively, you can define an action for every method of your Java file, as described here.

Community
  • 1
  • 1
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243