Yes! Sometimes you may react by thinking, "I suck," or at other times think "well, then you suck," and when you're hurt, either response is natural. It's similar to a physical injury--you may criticize yourself for being clumsy, you may blame the person who hurt you, resent the "weapon" (like when you cut yourself chopping up veggies), be angry with "chance," or you may feel a combination of all that. If you don't feel anything, you risk getting hurt again, at least until you find a way around or through it, so yeah, it's totally a defense mechanism.
If I may shift into counselor mode...
Allow yourself to feel that hurt for a little while instead of repressing it. Give yourself a chance to feel what's basically an emotional injury, then let it flow away like the little bit of blood that actually helps protect an open cut.
When you want to move on, replace that external rejection with internal healing--that corny thing called self-love is actually the way to recover on the inside, like when your blood creates a scab (the emotional pain subsides), your immune system neutralizes potential infection, and new skin cells and whatnot reconstruct the affected body part. It helps if you can recognize that the reason(s) the other person turned you down may have little or even nothing to do with you--and even if it does, that's OK! As long as you're not a major a-hole, as long as you're doing the best you can (or working towards self-improvement if you think it's appropriate), and as long as you're not choosing people who are incapable of a healthy relationship in the first place, you're cool!