coure2011
coure2011

Reputation: 42534

GET http://localhost:8080/system/users/modify/:id 400 (Bad Request)

I am getting following error on click of modify button

GET http://localhost:8080/system/users/modify/:id 400 (Bad Request) 

js code

 .when('/users/modify/:id', {
            templateUrl: '/system/users/modify/:id',
            controller: 'ModifyUserController'            
        })

here is java code

@RequestMapping(method = RequestMethod.GET, value = "/users/modify/{id}")
public String modifyUser(@PathVariable int id, @ModelAttribute(value = "loginModel") LoginModel loginModel, Model model) {   
    return "system/users/modifyUser";
}

it works if make the java header like this

public String modifyUser(@ModelAttribute(value = "loginModel") LoginModel loginModel, Model model) {

but I want to get the id in this method

Upvotes: 0

Views: 5356

Answers (2)

coure2011
coure2011

Reputation: 42534

Unfortunately its not auto binding the param variable and I have to apply it my self like this

templateUrl: function(param) {
    return '/system/users/modify/' + param.id;
},

Upvotes: 2

geoand
geoand

Reputation: 64099

Assuming that the call that is being picked up by the Web server is actually GET http://localhost:8080/system/users/modify/:id(the :id is not being replaced by Angular, or you are just calling it like that for testing purposes)

the problem is that you are specifying that id must be an int. But in this case where you are not sending an int, so Spring complains and a HTTP 400 is being thrown

Upvotes: 1

Related Questions