0

I'm using Angularjs and spring mvc 3. I have in my controller class:

@Controller
@RequestMapping(value = "/elprocesses")
public class ELProcessController {
...
@RequestMapping(value = "/elprocess", method = RequestMethod.POST)
public @ResponseBody void save(@RequestBody final Entity01 entity01, 
    @RequestBody final Entity02 entity02
        ) {
    ...
}

ELProcessController.js :

$scope.saveForm = function(selectedname01) {
    $http.post('elprocesses/elprocess', {entity01:selectedname01, entity02:selectedname02});
...
}

it doesn't enter in my spring controller method, but when I send only one data with $http.post('elprocesses/elprocess', selectedname01); and changing my controller class with:

@RequestMapping(value = "/elprocess", method = RequestMethod.POST)
    public @ResponseBody void save(@RequestBody final Entity01 entity01)

this works fine,

What am I doing wrong to send entity01 and entity02?

4

1 回答 1

1

在您的 javascript 中,是否在任何地方定义了 selectedname02?

如果是,请打开您的网络选项卡,您将看到它是否正在发送数据。POST 请求Content-Type: application/json默认具有标头,因此请确保您尝试获取 json 数据而不是形成编码数据或其他内容。我根本不熟悉 spring mvc,所以请查看他们的文档。

于 2013-08-21T23:57:42.500 回答