It's not made clear but in this interview with Sam Raimi (director of Spider-Man 2) he describes the genesis of the power-loss plotline;
“I was thinking about a great issue of Stan Lee’s Spider-Man comic
book where he gets the flu. And he, for a time, is really weak. It was
so human to me, I thought it was great. This superhero’s got the bug
that affects all of us, and just like we all have to go to work when
we’re sick and we really don’t know why we’re doing this and how we’re
gonna do our job, he had to fight criminals when he had the flu. I
thought that was incredibly human, a humanizing thing to have happened
to a super hero.
It was a combination of that and a desire to put that into the picture
so we could identify with him. I thought that was a unique thing that
happened in Stan Lee’s comics ..... That’s where the genesis of the loss of
powers came from.”
Although the implication is that in the film his power-loss is largely psychological (the doctor hints Spider-Man's inability to fully make use of his powers comes from a psychological barrier and because of his lack of motivation to remain Spider-Man) the fact remains that the plot-line was inspired by the comic "Spiderman : Unmasked at Last!" where his power loss is actually the result of a flu-like illness.