Okay, before we start let me just say I feel least qualified to do this. I feel I should write something more like "how to write stupid things" or "how to contribute without contributing"...actually, that sounds good I'm gonna write that. Well, let's get started shall we.
A hero is only as good as his heart, I think the saying was. Or I made that up just now. I'm not entirely sure. What I do know is your hero has to have something to believe in, whether that is patriotism (Captain America), a sense of duty (Ol' Web Head) or to kill scum (Punish-- wait, should he be here?!) He needs values and beliefs he hold higher than everything else, without those beliefs they wouldn't have anything to keep them going and would end up in the Lizard's jaws with a sprinkle of salt and a splash of...something. So yeah, onto part two.
There are many different types of hero, there's the spidey type where our lovable hero is just that nice and is always cheery, did I say spidey? I meant someone less depressed. But there are types when the hero, while not being an anti-hero, has an attitude less cheerful, where he just wants to save people and leave. Any attitude you give to your character is fine, as long as it isn't that of the outright villain.
Test of faith
Occasionally, your hero is going to have to question everything that he's fighting for, but don't worry he he regains his confidence/belief/whatever back in time to save the day against the major bad-guy. Or he turns evil. It's your story. This makes our hero stronger, both mentally and spiritually and means his beliefs are stronger than ever before. After this you may grant him a streak of unbeatable-ness (is that even a word) to show this to your readers.
Yes, a test of faith is fine occasionally to makes your readers wonder if your hero will turn out ok but obstacles are needed regularly. They can be a recurring villain, a new stronger villain or even a task your hero has to complete with a dreaded consequence. It doesn't even need to be about his her hero identity, give him an obstacle in his/her civilian life! Remember, it's fine to switch things up and have Jack/Jill stay at home once in a while with a "friend" while still trying to slip away to suit up and save the day.
But of course, only you should write your stories, this is but a guide. Have fun with it above all thing. This has been Cappie, signing off.