You're lucky that the cat doesn't respond aggressively, as cat scratch fever can be serious. I think you are correct to handle it as though he were hitting another child. And the cat will help you. Like other children who quickly learn to stay out of reach of a hitter, the cat will come to avoid your son.
Incidentally, I doubt that hitting the cat is attention-getting behavior. My guess would be that he is just “trying out” a new response and enjoying his newly acquired power as an advanced toddler. A little boy his age feels that he is king of the hill and that the cat, like all his other subjects, should exist for his own pleasure. Talk to him about it (“_____ doesn't like to be hit”), and let him stand beside you and participate when you hold and stroke the cat.
Our parenting advice is given as suggestions only. We recommend you also consult your healthcare provider, and urge you to contact them immediately if your question is urgent or about a medical condition.