0

In my js file, i have an Ext.Ajax.request to remove a user from a table. The most important thing is to send the username. This is my request code:

Ext.Ajax.request({
    url: 'deleteUser.html',
    method: 'POST',          
    headers: {'Content-Type': 'text/html'},
    waitTitle: 'Connecting',
    waitMsg: 'Sending data...',                                     
    params: {
        username:username
    },
    scope:this,
    success: received,                                    
    failure: function(){console.log('failure');}
});

In the firebug i can see the post myapp/admin/deleteUser.html. In the post tab appears username=example.

In the server-side i have a controller which catchs the post:

 @RequestMapping(method=RequestMethod.POST, value="/deleteUser")
 public @ResponseBody Map<String,String> deleteUserHandler(@RequestParam("username")String username, Model model){
    userService.deleteUser(username);
    Map<String,String> responseMap = new HashMap<String, String>();
    responseMap.put("message", "Success");
    return responseMap;
 }

if i have @RequestParam("username") i receive a 400 error (Incorrect request) and if i try another ways to get params i get null.

Could anybody help me please?

mannuk
  • 1,259
  • 5
  • 21
  • 43

1 Answers1

0
In the firebug i can see the post myapp/admin/deleteRole.html. 
In the post tab appears username=example.

you say you can see web calling deleteRole.html.

But in your ajax and your Controller it should be call "/deleteUser"

How if you log something in your controller so we can determine if that function have been called.

First try connection between your html mapped to your function correctly

@RequestMapping(method=RequestMethod.POST, value="/deleteUser")
public @ResponseBody String deleteUserHandler(@RequestParam("username") String username){
    System.out.println("deleteUserHandler called");
    return "{\"message\" : \"success\"}";
}

If your function called it should be ok..

Daniel Robertus
  • 1,100
  • 1
  • 11
  • 24