2
我正在使用spring boot 1.3.6實現一個web服務。在我的控制,我有這樣的方法:在一個類中收集多個查詢參數
@RequestMapping(value = "/employees/{id}", method = RequestMethod.PUT)
createEmployee(@PathVariable String id,
@QueryParam(required = false, value = "department") Set<String> departments)
我想收集請求參數中像一個類:
class EmployeeParams {
public String id;
public Set<String> departments;
}
我試着使用:
@RequestMapping(value = "/employees/{id}", method = RequestMethod.PUT)
createEmployee(EmployeeParams param) { ... }
但它確實不行。我在上面的課上得到了id,但是沒有上課。在Spring請求中收集請求參數的正確方法是什麼?