Causes
Trauma (scratches, branches), foreign bodies, dry eye, abnormal eyelashes, infections. Brachycephalic breeds (Bulldog, Pug, Persian) are very prone to them because of their prominent eyes.
Diagnosis
The vet stains the cornea with fluorescein: the ulcer becomes visible as a green area.
Treatment
Antibiotic and supportive eye drops, pain control, and an Elizabethan collar to prevent rubbing. Deep ulcers may need surgery. NEVER use corticosteroid eye drops on an ulcer — they make it much worse.
Prevention
Protect the eyes in breeds with prominent eyes, treat conjunctivitis and dry eye promptly, and avoid areas with branches at eye level.

