我有一個整數列表在客戶端控制器:Angular JS:如何將列表作爲角js中的參數傳遞?
selectedSegments = [19,26]
現在,我需要從客戶端這個列表傳遞給後端因此,我調用後端服務爲:
return $http.post('dde/segments/deleteSegmentsForSelectedClient' ,{segmentIds: segmentIds })
.then
(
function(response)
{
return response.data;
},
function(errResponse)
{
console.error(' Error while getting results of query' + errResponse);
return $q.reject(errResponse);
}
);
和服務(Java類)身邊,我有:
@RequestMapping("/dde")
@RestController
public class SegmentController
{
@Autowired
@Qualifier("apiSegmentService")
private SegmentService segmentService;
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@RequestMapping(value = "/segments/deleteSegmentsForSelectedClient", method = RequestMethod.POST)
@Transactional(transactionManager = "apiTransactionManager", propagation = Propagation.REQUIRED)
public ResponseEntity<Void> deleteSegmentsForSelectedClient(@PathVariable("segmentIds") List<Integer> segmentIds)
{
for(int id: segmentIds)
{
try
{
segmentService.deleteSegmentEntity(id);
}
catch (ParserException e)
{
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
}
return new ResponseEntity<>(HttpStatus.OK);
}
}
此類工作的罰款與其他功能,並與其他類型的PARAMS但當我試圖通過列表作爲PARAM我得到500錯誤與錯誤信息:
Missing URI template variable 'segmentIds' for method parameter of type List
我可以得到幫助如何傳遞參數列表?請讓我知道我應該提供更多信息