How to call Spring controller function from JQuery Data tables AJAX
<p>I have a controller defined in controller.xml as </p>

<pre><code>&lt;bean name="/userController" class="UserController"&gt;
</code></pre>

<p>And I have UserData.jsp which renders the dynamic table as below.</p>

<pre><code>    &lt;table id="usermaintenancetable"&gt;
        &lt;thead&gt;
            &lt;tr&gt;
                &lt;th width="10%"&gt;User Id&lt;/th&gt;
                &lt;th width="5%"&gt;Password&lt;/th&gt;
                &lt;th width="5%"&gt;Level&lt;/th&gt;
            &lt;/tr&gt;
        &lt;/thead&gt;
    &lt;/table&gt;
</code></pre>

<p>In datatable.js file I have to access the controller to fetch data using ajax.</p>

<pre><code>$(document).ready (function() { 
   $('#usermaintenancetable').DataTable( {
        //How to call controller from here using ajax call
   });
});
</code></pre>

<p>I have written an ajax function like below.</p>

<pre><code>"ajax" : {
        "url" : "/userController",
        "dataSrc" : "users",
        "type" : "POST"
    }
</code></pre>

<p>But I am getting below ajax error.</p>

<blockquote>
  <p>POST <a href="http://localhost:7001/userList" rel="nofollow">http://localhost:7001/userList</a> 404 (Not Found)send @ jquery.js:10261ajax @ jquery.js:9750ra @ jquery.dataTables.js:781ga @ jquery.dataTables.js:1065(anonymous function) @ jquery.dataTables.js:2016each @ jquery.js:370each @ jquery.js:137m @ jquery.dataTables.js:1831h.fn.DataTable @ jquery.dataTables.js:3853(anonymous function) @ datatable.js:3fire @ jquery.js:3232fireWith @ jquery.js:3362ready @ jquery.js:3582completed @ jquery.js:3617</p>
</blockquote>

<p><strong>Edit: Added Controller code</strong></p>

<pre><code>import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
public class UserController extends AbstractController{
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest req,
        HttpServletResponse resp) throws Exception {
     String action = ServletRequestUtils.getStringParameter(req, "action", "view");
    System.out.println("Action: " + action);
    if("list".equalsIgnoreCase(action)) {
        //added some logic to get data and set it to table
    }
    return null;
} }
</code></pre>

<p>Could you please help in this?</p>