Spondylitis is term used to indicate aging process of spine . Considering your age it looks like a mechanical neck pain. It is seen in all age groups. It is very common in today's time due lifestyle changes ( using lot of computer ,mobile, sitting jobs). You should get your self assesd by physio if possible a cert.mckenzie therapist and follow exercise program and ergonomic changes. As for gym it's alright to it . But avoid heavy weight training of your arm of any exercise which involves neck bending.
Nice question, 1st @ 22 yrs of age u will not get cervical spondylitis. By straining a lot u should have got muscle spasms that is imitating as spondylitis. Spondilitis means degenerative changes in the disc of the spine. When pain is there in the muscle exercises are contra indicated. Once the pain got reduced with some form of muscle release or muscle relaxation therapy then u have to plan for neck strengthening exercises. Make a note that after muscle strengthening exercises only u should start on ur gym( weight training) or any form of workouts. Best home treatment till u see a Physio is ice therapy and rest to that part will heal your muscle injury. Seeing an Physio will give u permanent result.