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 6190521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:36:16+00:00 2026-05-24T02:36:16+00:00

I created an action in struts 2 class MyAction extends ActionSupport { private List<User>

  • 0

I created an action in struts 2

class MyAction extends ActionSupport {
    private List<User> users;
    //getters and setters users
    public String execute(){
       users=//code to get users;
       return SUCCESS;
    } 
}

I mapped this action class with url /MyAction and the success result is a jsp which displays the users when i open the url:

http: //localhost:8080/MyAction.action

When I open the page as:

http: //localhost:8080/MyAction.action?xyz=123

I do not get any error. But when I open the page as:

http: //localhost:8080/MyAction.action?users=123

Struts tries to call setUsers() method and fails to convert 123 to a list of Users. Hence I get an Conversion error.

Since the action is not expecting any parameter it should behave in same way to all extra parameters provided. It should not just ignore few and show error for others.

The solution that I was able to find for this problem is to make all the setter methods private except for the setters for expected parameters.

Does anyone has a better solution?

  • 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-24T02:36:17+00:00Added an answer on May 24, 2026 at 2:36 am

    Thanks for your replies. I understand that this is struts functionality, but what I’m pointing out is that if struts is ignoring other parameters (for which there is no setter) it should ignore all the parameters that the action does not require. But yes, there should be some way for specifying the list of acceptable parameters.

    As Quaternion pointed out ParameterNameAware is a solution but this works when there is only one action method in the action class or all the action methods must accept the same list of parameters.

    I have found another way of specifying the list of acceptable parameters for each action using the params interceptor.

    <action name="xxx" class="yyy" method="action1">
       <intercecptor-ref name="defaultStack">
         <param name="params.excludeParams">regex</param>
       </intercecptor-ref>
       <!-- other code -->
    </action>
    

    in place of regex you specify the regular expression for the excluding the parameters except for the ones that are not excepted by your expression.

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

Sidebar

Related Questions

I created the following interface: <?php interface Action { public function execute(\requests\Request $request, array
I have a problem with authorized SSL connection. I have created Struts Action that
I am trying to create a PDF file using struts 2.Action class location is
I'm trying to make it so when a model is created via created action
I created a vbscript custom action which checks for some registry keys and alters
I created a button and added an action for it, but as soon as
I created a UIButton programmatically and I want to create an action to handle
When I call a static method like: Something.action(); Since a instance isn't created how
I'm having trouble calling a method in one Struts action from a method in
I have a Struts + Velocity structure like for example, a Person class, whose

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.