In the same way that choosing a good pillow helps support your neck, selecting the right mattress for your spine to support your posture is equally important. It's true that your body type will largely dictate the type of support you need, with the general rule being if your hips are wider than your waist, a softer mattress can accommodate the width of your pelvis and allow your spine to remain neutral. Although if your hips and waist are in a relatively straight line, a firm surface offers better support. Whilst we obviously can't easily control our posture when we sleep, at least a supportive mattress will help keep your posture in check.
There are so many different types of mattresses on the market today and for people with spinal issues or poor posture, a foam mattress rather than one with inner springs will largely be preferable. This is because springs or pocket springs can create pressure points on the body and don't support the natural curvature of the spine. By comparison, foam mattresses adjust to the contours of the body, so as you move in your sleep, your bed adjusts to you.
The excellent page Sleep like the Dead has a great comparison of a variety of mattresses and some great pointers on what to look for when buying a new one. There are also several interesting startups like Casper and Tuft and Needle producing some great value, well-engineered foam mattresses and they also offer 100 day free trials meaning you can test it out before you buy.
So do you research before you spend the cash and try out a variety of beds and find one that's right for you. You spend 1/3 of your life sleeping so do it right!