PHILADELPHIA — Hillary Clinton fired back at Donald J. Trump over national security on Monday, declaring that she would shore up the nation’s alliances rather than unravel them, listen to military leaders rather than herself, and never order American troops to commit war crimes.

Offering a preview of her foreign policy counterpunch to Mr. Trump on the opening day of the Democratic National Convention, Mrs. Clinton told the V.F.W. Convention in Charlotte, N.C.: “I believe in standing with our allies. Generations of American troops fought and died to secure those bonds. They knew we were safer with more friends and partners.”

Mrs. Clinton, the presumptive Democratic nominee, did not mention her Republican opponent by name. But she laced references to him throughout the speech, her most sustained rebuttal to the policies Mr. Trump laid out during the Republican convention.

“You will never hear me say I will only listen to myself on national security,” Mrs. Clinton said, referring to Mr. Trump’s comment that he would keep his own counsel as commander in chief. She said she would listen to generals and admirals, and underscored her ties to the military by announcing the endorsement of a prominent retired general, John R. Allen.