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

  • Home
  • SEARCH
  • 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 6328135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:24:17+00:00 2026-05-24T17:24:17+00:00

I make an ajax request using jquery, this calls the following spring controller: @RequestMapping(value

  • 0

I make an ajax request using jquery, this calls the following spring controller:

@RequestMapping(value = "/dialogController", method = RequestMethod.POST)
public String dialogController(Model model, @RequestBody MyClass myclass) {
  myClass.setTitle("SUCCESS");       
  model.addAttribute("myClass",myClass);
  return "dialogContent";  //this resolves to dialogContent.jsp
}

However I receive the following error :

org.springframework.web.HttpRequestMethodNotSupportedException: 
Request method 'POST' not supported

And if required here is the ajax call I am making using jQuery:

   jq.postJSON("/dialogController", myClass, function(data) {
      myDialog.html(data);
      myDialog.dialog('open'); 
      //dialog settings previously assigned, 
      //but the success callback function is not reached anyway
    });

EDIT
I get same error if I use :

jq.ajax({
  type: 'POST',
  url: "/dialogController",
  data:myClass,
  success:  function(data) {            
         previewDialog.html(data);
         previewDialog.dialog('open');
  });
  • 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-24T17:24:19+00:00Added an answer on May 24, 2026 at 5:24 pm

    For the viewers at home … I found that the problem was due to the method signature defined in controller not matching the ajax call. I removed the Model model parameter from controller method. I also then realized I had to also return a new model and view; here is the working code:

    var myJSON  = {"title":"help"}; 
    myJSON = JSON.stringify(myJSON);
    
    <c:url var="postAndView" value="/PostJSONMAV" />
    ...
    jQuery.ajax({
        type: 'POST',
        url: "${postAndView}",
        data:myJSON,
        contentType: "application/json",
        success:  function(data) {          
            previewDialog.html(data);
            previewDialog.dialog('open');
        }
    });
    

    I changed to the ajax call but jQuery.postJSON() will probably work aswell. And shown below is the new controller code, which corrrectly adds a new object to model and returns jsp page, which is opened up in a dialog:

    @RequestMapping(value = "/PostJSONMAV", method = RequestMethod.POST)
    public  ModelAndView postJSON(@RequestBody MyClass myClass) {
        ModelAndView mav = new ModelAndView();
        myClass.setTitle("SUCCESS");
        mav.setViewName("dialogContent");
        mav.addObject("myClass", myClass);
        return mav;     
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code from http://www.joe-stevens.com/2010/01/04/using-jquery-to-make-ajax-calls-to-an-asmx-web-service-using-asp-net/ function callWebService(address) { var result; $(#result).addClass(loading); $.ajax({
I am trying to make two ajax requests in parallel using jQuery like this:
I make an AJAX request like so using JQuery: $.ajax({ type: GET, url: getvideo.php,
I am using jQuery to make an AJAX request to a remote endpoint. That
I am using jQuery to make some ajax calls and wonder how people handle
im using jquery to make ajax requests. is it possible to detect if the
I am using asp.net mvc and jquery to make ajax requests and when the
I use this pseudo-class to make Ajax request to server: function RequestManager(url, params, success,
I am using JQuery to perform form submission through an ajax request. I use
I'm using the following ajax function: function callAjax(request,callback) { if (window.XMLHttpRequest) {// code for

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.