In Star Trek, the crew of a starship is free to move about their ship without the problems of weightlessness because of a network of small generators working together to provide 'artificial' gravity.  The gravity field itself is created by a controlled stream of gravitons, using the same principles as the Star Trek tractor beam.  According to The Star Trek The Next Generation Technical Manual,  the gravity generators use superconductor technology, where a superconducting stator of thoronium arkenide is suspended in pressurized chrylon gas. In a memorable scene from the movie Star Trek VI: The Undiscovered Country, the Klingon ship Kronos One is hit by photon torpedoes and its artificial gravity field fails. The whole ship experienced weightlessness for several minutes while assassins boarded and killed several members of the crew, including Chancellor Gorkon. 

Artificial gravity generator, as depicted in the
The Star Trek: The Next Generation Technical Manual
Living in zero-gravity environments for extended periods of time can produce detrimental health effects on humans, such as muscle atrophy and deterioration of the skeleton, slowing of the cardiovascular system, decreased production of red blood cells, balance disorders, and a weakening of the immune system. Many of the conditions caused by exposure to weightlessness are similar to those resulting from aging.  To address this problem, modern-day space research has focussed on the only substitute for gravity in a zero-gravity environment - the force created by acceleration. The only acceleration that can be sustained without continuous energy input is centripetal acceleration - that is, rotation.  A rotating spacecraft will produce the feeling of gravity on its inside hull. This centripetal force drives any object inside the spacecraft toward the hull, thereby giving the appearance of a gravitational pull directed outward. The Stanford torus space station design, for example, rotates once per minute to provide between 0.9g and 1.0g of artificial gravity on the inside of its outer ring via centripetal acceleration.

The Stanford Torus