Yang Jia, 28, an unemployed man from Beijing, attacked a police station in China's most populous city on July 1 last year.
Carrying a knife, a hammer, a mask, aerosol spray, and homemade explosives, he first stabbed the guard at the entrance to the Shanghai police station, then started a fire at the gate before bursting inside and attacking the officers.
Yang reportedly told investigators that his attack was revenge for mistreatment last October by police who had accused him of stealing bicycles. Local media said that Yang claimed he was beaten during questioning. Police denied the accusations.
Psychiatrists have determined that Yang was aware of his crimes and that he was mentally fit to stand trial for them.
Capital punishment in China is used for a range of crimes from corruption to murder.