Spider Web prevents the target from switching out or fleeing (including via Teleport). It bypasses accuracy checks to always hit, unless the target is in the semi-invulnerable turn of a move such as Dig or Fly. Spider Web's effect only applies as long as the Pokémon that used it remains in battle.
The affected Pokémon can still switch out via Baton Pass, but in that case, the Pokémon that switches in will now be affected. Conversely, the Pokémon that used Spider Web can switch out with Baton Pass and the effects of Spider Web will still apply. Also, if the affected Pokémon is Roared at or hit with a Whirlwind, they will still be switched out.
If a wild Pokémon uses Spider Web on the player's Pokémon, the player will be unable to escape.
If a Pokémon traps a target with Spider Web and then switches with Baton Pass the target will no longer be trapped. Pokémon affected by Spider Web can switch out with Volt Switch. Also, Dragon Tail and Circle Throw will force the affected Pokémon to switch out.