If you observe closely and compare cactus with other plants you'll find that cactus lack leaves. Instead they have spines. This is a special adaptation of cactus as well as other desert plants. These spine like structures helps preventing the loss of water and mineral content in the desert plants. The stem is typically succulent, meaning it is adapted to store water.
Photosynthesis takes place in the stems (which may be flattened and leaf-like in some species). Botanically, "spines" are distinguished from "thorns": spines are modified leaves, and thorns are modified branches. Cacti produce spines.