Cases of espionage have received wide attention in China recently. In January, officials announced that they were prosecuting a Canadian man who ran a cafe near the border with North Korea on charges of spying and stealing state secrets. Last year, China detained four Japanese citizens on suspicion of espionage.

As part of National Security Education Day on Friday, Beijing officials hung posters at government offices warning about the risks of romantic relationships with foreigners, according to The Associated Press. The posters, titled “Dangerous Love,” told the story of how a spy named David, posing as a visiting scholar, seduced a young propaganda worker and persuaded her to give him secret documents.

The details of Mr. Huang’s case were revealed in a 15-minute special report on CCTV, which portrayed him as a disgruntled employee who contacted foreign spy agencies online in hopes of getting rich.

Mimicking the style of several recent televised confessions that the ruling Communist Party has used as a propaganda tool, the report showed Mr. Huang in shackles and an orange vest, shuffling down a dark hallway. In an interview with CCTV, he recounted how he arranged meetings in Southeast Asia with foreign spy agencies and stole materials from his wife and brother-in-law, who also handled classified information in their work.

“If there are other people who see me and they are doing similar things — betraying their country — I hope they’ll report themselves to the national security people,” he said in the interview. “That’s good for their family and themselves, and it will lead to a better outcome.”

Mr. Huang was arrested in 2011, and it was unclear why the authorities waited until now to publicize the case. His wife was sentenced to five years in prison, and his brother-in-law was sentenced to three years in prison, the state media reports said. They were both accused of negligent disclosure of state secrets.