DS (7) has long hair. He's a very outgoing, confident child, but even so it is a struggle sometimes. We talk about it a lot. Here's some of the ways we try to handle adverse comments.
As people have already suggested - google footballers with long hair. It helps if he can say "well so-and-so has long hair and he's scored x this season/been capped y times for England" or whatever.
Always make clear that it is the stupidity of the commenter, not his hair, that is the problem.
Also make it clear that you'll support whatever choice he makes - whether to keep it long or cut it. Yes, I want to support and encourage him not to be a sheep, but if he decides that it's just not worth the hassle, I also want him to be able to cut it without feeling that I think he's "chickened out" (yet another of those amazing high-wire acts parenting requires!)
And I do tell him it looks lovely - because it does!
(He does have a fringe- his choice).
I'm lucky in that his teacher has been great about it. The thing that upsets him most are the comments from adults saying he looks like a girl. (Fair enough if it's a genuine mistake - but if it is, apologise and change the subject, don't keep saying "but you know, he looks really like a girl, etc. etc.")