Java - 将多个参数传递给ajax帖子

时间:2018-01-12 13:16:18

标签: java ajax spring

我有一个来自ajax请求的简单控制器。它工作但我想返回很多东西,不仅仅是List TestFlow.getFlow(flowName);

 @RequestMapping(value = "/execute-flow/getFlow" , method = RequestMethod.POST)
public @ResponseBody List<String> getFlow(@RequestParam("flowName") String flowName) {
    return TestFlow.getFlow(flowName);
}

我可以将多个内容返回到ajax帖子吗?

例如:

 @RequestMapping(value = "/execute-flow/getFlow" , method = RequestMethod.POST)
public @ResponseBody List<String> getFlow(@RequestParam("flowName") String flowName) {
    return TestFlow.getFlow(flowName);
    return TestFlow.getInputs(flowName);
    return TestFlow.getCode(flowName);
}

1 个答案:

答案 0 :(得分:0)

不确定你到底发生了什么,但是

return Arrays.asList(
        TestFlow.getFlow(flowName),
        TestFlow.getInputs(flowName),
        TestFlow.getCode(flowName));
只要所有这些都属于同一类型(String),

就可以工作。