Spraying urine is a normal territory-marking behaviour. Never punish a cat for spraying as this never helps but may lead to more spraying. Try to understand the causes of your cat's behaviour instead.
What is urine spraying?
Urine spraying is completely different from normal toileting. Cats usually urinate from a squatting position and produce a large puddle of urine in a secluded spot.
In contrast, cats spray urine to leave a scent message for themselves and other cats. Cats spray by backing up to a vertical surface in an open location and squirt a spray of urine from a standing position, sometimes while paddling with their back legs and quivering their tail.