Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6053999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:06:11+00:00 2026-05-23T08:06:11+00:00

I have seen many tutorials in which action has many methods other than execute

  • 0

I have seen many tutorials in which action has many methods other than execute

public class UserAction {

    public TestAction() {
    }

    public String execute() throws Exception {
      System.out.println("hello i aam action");

        return "success";
    }

    public String addUser(String name)
    {

     return "success";


   }

    public String listUser(String name)
    {

     return "success";


    }

    }

the action mapping is done like this

  <action name="addUser" method="addUser" class="com.vaannila.web.UserAction">
  <result name="success" type="redirect">listUser</result>
</action>

<action name="listUser" method="listUser" class="com.vaannila.web.UserAction"> 
  <result name="success">/register.jsp</result>
 </action>

I a unable to understand it.How listUser is getting called?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:06:12+00:00Added an answer on May 23, 2026 at 8:06 am

    I don’t think this works because your mapping is pointing to methods (add, list) that do not exist. You have addUser and listUser in your action so your mapping have to point to the same methods.
    Back to your question I have to say Struts2 has a feature that let’s you pack a couple of methods into the same action. This is specially useful when you want to perform CRUD operations. One way is to explicitly predetermine the method you want to call in you mapping:

    <action name="listUser" method="list" class="com.vaannila.web.UserAction"> 
        <result name="success">/register.jsp</result>
    </action>
    

    If you point your browser to http://yourDomainHere/listUser your list method in your UserAction action will be executed. You can also use wildcard mapping here like:

    <action name="*User" method="{1}" class="com.vaannila.web.UserAction"> 
        <result name="success">/register.jsp</result>
    </action>
    

    In this case you can replace asterisk (*) with any method in your action. This mapping will take first placeholder ({1}) in the mapping as a method and call it. So you can point your browser to: http://yourDomainHere/listUser and http://yourDomainHere/addUser knowing the same mapping will handle both and your respective methods will be called.

    Edit for the comment
    I think I got your point. In the example you provided listCustomer is never called. It’s the addCustomer that populates the customerList before sending success and since it has provided a getter method for the list, back in the page you can access it and iterate it and show the values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen many php scripts in which you can cascade class method to
I have seen many tutorials on how to compress a single file in c#.
I have seen simple example Ajax source codes in many online tutorials. What I
I'm learning javascript for a new project. I have seen many tutorials about javascript
I have seen the word Tombstoning in many tutorials. I did not get what
I've seen many tutorials, but none of them have worked in my case, I
I have seen many tutorials, but they're so confusing, and to do what I
OK I have seen many tutorials on how to use URL routing. However, I'd
In many tutorials, i Have seen the code below : response.setStatus( ...); What is
I have seen many tutorials where the hibernate is implemented using annotations (basically hibernate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.