Hi, A.-
I really feel for you. This must be very frustrating. I know that I have now almost "run the gamut" of phases (my oldest just graduated), and hitting is still the behavior that gets my dander up the most. It must be a mom thing or a female thing, because my husband takes it in stride as well as any other misbehavior. Anyway, just to say "I feel for you!"
I do want to say that spanking, if done correctly, is not confusing to a hitting child. We really need to give the children credit--they are very smart. They know that what they do and what you do are not the same (unless they are--you should never be "hitting" a child). My children have all been spanked at some time, and none of them have had ongoing problems with hitting as a result.
I wanted to queue in on a few things that you said. When you said that he hit your husband for really no reason, do you mean that he wasn't provoked at all? Or was this another case of not getting his way? If it's really for no reason, it seems a bit odd. But I think you mean for no reason that makes much sense to us. In that case, you may want to spend some time trying to really figure out what is driving him to do it. Discipline works so much better if you can get to the feelings or understandings behind the behavior.
You mentioned a few things that you have done about it (spanking, putting in his room, explaining). If you are doing something different each time, then that might be confusing. It works much better to decide on one consequence that is motivating enough and then apply that same consequence every time. Try not to let it go even once, or any more than you can truly help. And try not to react differently--keep it very predictable.
As far as certain punishments, I don't think the room thing is the best idea for training at this age. It probably makes him very angry, which ruins his chance to learn anything. And within a few seconds he's probably forgotten why he's there. Something you can administer immediately and be finished with quickly is really best. That's why I use spanking at this age. Understand that he's just being a normal little guy testing his limits and that it is a good thing in that way (he's giving you a great teaching opportunity) and you may find that it doesn't make you angry. Then a quick spanking (I assume you know how little it takes--if not, do NOT use this method) with a very short explanation and then a time of cuddling is all you need.
You said it has been going on for several months--that's how you know it's not just a phase. But I assume that doesn't mean you have been consistently been working on it for that long. So consider the beginning of your consistent training to be your starting point and be ready to be patient with your method for a little while (sometimes such little ones need lots of repetition) and it probably won't seem like so long that you have been dealing with it.
Enjoy that little guy! He'll be grown up so fast (and you'll be laughing about this), but today he's yours to hold.