Lawmakers in Spain have voted to send about 400 troops to join anti-piracy patrols off the coast of Somalia .