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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:12:34+00:00 2026-06-05T07:12:34+00:00

I am working on a project that the project is going to use Ajax

  • 0

I am working on a project that the project is going to use Ajax to post JSON object to Springs-MVC. I been making a number of changes and I got it to the point where I dont get any more errors BUT I dont see the data that is getting POSTed to Spring in the object I need it in.

Here is my Spring Controller.

@RequestMapping(value="/AddUser.htm",method=RequestMethod.POST)
    public @ResponseBody JsonResponse addUser(@ModelAttribute(value="user") User user, BindingResult result ){
        JsonResponse res = new JsonResponse();

        if(!result.hasErrors()){
            res.setStatus("SUCCESS");
            res.setResult(userList);
        }else{
            res.setStatus("FAIL");
            res.setResult(result.getAllErrors());
        }

        return res;
    }

I put a breakpoint in and my USER object never gets the data. next is a copy of my USER object:

public class User {

    private String name = null;
    private String education = null;

    private List<String> nameList = null;
    private List<String> educationList = null;

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getEducation() {
        return education;
    }
    public void setEducation(String education) {
        this.education = education;
    }
    public List<String> getNameList() {
        return nameList;
    }
    public void setNameList(List<String> nameList) {
        this.nameList = nameList;
    }
    public List<String> getEducationList() {
        return educationList;
    }
    public void setEducationList(List<String> educationList) {
        this.educationList = educationList;
    }

and now for the javascript code that does the Ajax, JSON post:

function doAjaxPost() {  

      var inData = {};

      inData.nameList = ['kurt','johnathan'];
      inData.educationList = ['GSM','HardKnocks'];

      htmlStr = JSON.stringify(inData);
      alert(".ajax:" + htmlStr);


    $.ajax({
         type: "POST",
         contentType: "application/json; charset=utf-8",
         url:  contexPath + "/AddUser.htm",
         data: inData,
         dataType: "json",
         error: function(data){
              alert("fail");
         },
         success: function(data){
              alert("success");
         }
         });

};

Please let me now if you can help?? I have to get this working ASAP… thanks

  • 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-05T07:12:35+00:00Added an answer on June 5, 2026 at 7:12 am

    You also need to specify the header in your RequestMapping annotion found in your controller.

    @RequestMapping(headers ={"Accept=application/json"}, value="/AddUser.htm", method=RequestMethod.POST)
    

    Also, remove .htm in your URL path. htm is some kind of request type overide. Using .htm specifies the web server to handle the request as a classic html request. Using .json would specify to the webserver that the request expects to be handled as a json request.

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

Sidebar

Related Questions

I'm working on a project that makes heavy use of jQuery tabs and Ajax.
I'm going to be working on a project that involves a number of elements:
I've been working on a ASP.NET project that is going to save uploaded files
I am working on a project that is going to use CouchDB for flexible
I am currently working on a private project that is going to use Google's
I'm working on a project that is going to make heavy use of JBoss
I'm working on a new project that is going to make heavy use of
I'm working on a project that is going to be heavily templated, but the
I am going to be working on a project that will heavily involve indexing
I'm working on a project right now that required me to use a CMS

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.