lundi 1 juin 2015

Send json object with another parmeter to the controller in spring mvc

1.- I want to recive this two paramters like this in my controller :

*/Controller

@RequestMapping(value = "/insertCatalogGeneric", method = RequestMethod.POST)
    public @ResponseBody
    String insertCatalogGeneric(@RequestBody CatalogGeneric catalogGeneric , String tableName) {

        String table_name = tableName;
        String catalogInserted = catalogGenericService.insertCatalogGeneric( table_name, catalogGeneric);

        return catalogInserted;
    }

2.- I send to the contoller in this way...

$.ajax({
                        url : 'insertCatalogGeneric',
                        type : 'POST',
                        data:  {'catalogGeneric' : JSON.stringify(description_data) , 'tableName' : "fadsf"},
                        async: true,
                        cache: false,


                        contentType: "application/json; charset=utf-8",
                        success:function(data, textStatus, jqXHR) {

3.- In my debug I receive error 400 not found the direction .... i know that is for the way that i send the parameters , but what will be the correct form to do that ?

Aucun commentaire:

Enregistrer un commentaire