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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:45:08+00:00 2026-06-07T18:45:08+00:00

If a struts 2 action class have a property of List<User> userList . And

  • 0

If a struts 2 action class have a property of

List<User> userList.

And the user class has properties like

username, password, createdDate etc.

Is it possible to make struts populate the list by passing the appropriate JSON string, while submitting a jQuery ajax request pointed at that action.

If it is possible how? Specially how will the JSON string have to look like?

Please ask any clarifications.

EDIT : I’m sorry if I wasn’t clear enough. What I want to do is not get data from Action to a JSP, or submit a form to populate the data. I want to submit a AJAX request with JSON data which Struts 2 can use to automatically populate the List in the Action class.

Not submit the form with AJAX.

  • 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-06-07T18:45:10+00:00Added an answer on June 7, 2026 at 6:45 pm
    1. you should define your action result type="json" and check you have json plugin on your classpath, make sure you have

      <struts>
          <package name="your_package" extends="struts-default, json default" namespace="/">
          // your action here
          </pacakge>
          ...
      </struts>
      
    2. edit your action class like this

      public class myAction extends ActionSupport {
          private List<User> userlist; // getter and setter
          public String execute() {
             // your moves
             return SUCCESS;
          }
      }
      
    3. then you can do some on your jsp page to show the result like:

      <s:iterator list="userList">
        <s:property value="username"/>
        <s:property value="password"/>
        <s:property value="createdDate"/>
      <s:iterator>
      

    I hope this can help you..

    UPDATE

    if you have already a json object:

    {
       "userList" : [
          {"username" : "username", "password" : "afgasdfa", "createdDate" : "date-in-format"},
          {"username" : "username", "password" : "afgasdfa", "createdDate" : "date-in-format"},
          {"username" : "username", "password" : "afgasdfa", "createdDate" : "date-in-format"},
          {"username" : "username", "password" : "afgasdfa", "createdDate" : "date-in-format"}
       ]
    }
    

    this should be the format.

    then you should get this object from your action class with List<User> userList

    just try it and feedback.

    UPDATE 2

    maybe you should get your json object using String, then convert it to Java Object using:

    String stringObject; // which get your string from http
    List<User> userList;
    
    userList = (List<User>)JSON.deserialize(stringObject,List<User>.class);
    

    Please feedback again.

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

Sidebar

Related Questions

So in struts I have an action form which has 5 properties. Each property
I have a model-driven Struts Web action: public class ModelDrivenAction<T extends Object> implements ModelDriven<T>,
My Action class have the following methods, 1.add 2.edit 3.loadEdit 4.remove 5.list 6.execute in
In Struts 1 you could have, in struts-config.xml, a declaration like: <action path=/first forward=/second.do>
I have a jsp page and struts 2 Action class . When I submit
I have a struts and hibernate project, From the action class, I need to
I have a Struts + Velocity structure like for example, a Person class, whose
I have this configuration in struts.xml <action name=updateAction class=it.myApp.action.ajax.UpdateActionAction> <result name=success type=json/> <result name=error
I am working on struts2. In my action class I have written some accessors
I have a html form with action attribute pointing to struts action Here is

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.