iOS 11, like other versions of the software, show previews of your messages and emails on your lock screen, allowing anyone with access to your iPhone or iPad to take a glimpse.
To limit this feature, for example, to just showing the sender of the message, go to Settings > Notifications and then select Messages and Mail for text messages and iMessages and email, respectively. From each screen, you can change the preview style. For maximum privacy, disable Show Previews so messages won’t be displayed on the lock screen.
A new feature, dubbed Persistent Banners, will alert you but require action before moving on.