I have a list of integers at the client side controller as :
selectedSegments = [19,26]
Now, I need to pass this list from client side to the back end hence I am calling the back end service as :
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 );
}
);
And service (java class) side I have :
@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 );
}
}
This class is working fine with other functions and with other type of params but when I am trying to pass a list as param I am getting 500 error with the error message:
Missing URI template variable 'segmentIds' for method parameter of type List
MAy I get help on how to pass param as list? Please let me know should I provide more information