Armor makes a HUGE difference to a melee fighter. If you sent your hammerdwarves in to fight the goblins unarmored, with low skills, and low-quality hammers, yeah, they're going to get beat up pretty bad. Most deaths in combat are caused by a blow to the head, heart, or vitals, so even just simple iron mail, breastplates, helms, and shields protect against a large proportion of instant-kill attacks. It worked for the Romans, and it will work for you too.
Weapon traps tend to get jammed, especially if you put 10 weapons in each trap like some people suggest. I don't do this myself; sure, it vaporizes the first poor gobbo to step on the thing, but it's virtually certain to get jammed on the first hit, thus making it useless for the next gobbo who comes along. I generally just put 1 large serrated disc and 1 spiked ball in each trap, plus whatever useless goblinite I happen to have around; this still usually kills/multiple-amputates any goblins or trolls, and it usually manages 3-4 attacks before jamming. It's also good to set up your traps on a precarious catwalk above a long fall onto spikes, in case you get any skilled dodgers in your goblin attacks.
As far as starting military, I generally try to arrange for one of my starting dwarves to have a non-demanding job (like expedition leader) and be mostly military-focused. Give him Armor User at embark, which is the hardest military skill to train up. Get him a helm, mail, breastplate, and shield as fast as manageable; Shield User is one of the best defensive skills, and helm+mail+breastplate blocks almost all instant-kill attacks. As the fortress progresses, recruit any immigrants with no useful skills (high master lye maker, proficient dyer, "peasant", you've seen them) into the military, so that by the time you start to worry about sieges at 80 dwarves, you have a full melee squad and a mostly-full crossbow squad. Soldiers set to train no longer forget to eat, so you can safely set them to "Train, 10 min" all year and they should get high enough that they no longer mind long patrol duty just before they get angry enough about it to go on a ballistic rampage. Probably. If the
"long patrol duty" bug ever gets fixed, you might want to give each squad one month off every season, but as it stands this doesn't actually prevent the bad thought so the only hope is to train them to champions quickly. Danger rooms work great for this purpose; if you think this is an exploit, I agree with you but it appears to be the only way to get them trained high enough in time to work around the bug, because sparring is so gimped and hard for them to set up.
Weapons and armor are hugely dependent on quality, so try to get a high-level weaponsmith and armorsmith. You might even consider bringing those skills at embark, they're relatively uncommon skills for immigrants. (If I had one Proficient Weaponsmith for every three High Master Potash Makers I've got as immigrants, I'd have a lot more weaponsmiths than I've in fact seen.) The easy way I found to train them up is to order tons of armor and weapons made through the manager, and constantly melt down any that didn't come out at least "exceptional", but the fuel cost tends to be prohibitive until you have magma. Quality of mechanisms in weapon traps is also important, but trap-specific weapons are so insanely deadly (serrated discs especially) that their quality doesn't matter as much as for hand weapons.
War dogs are good too; they're not much use offensively but they serve as a great distraction. Just don't make the mistake I did the first time and assign them to your soldiers; if you do this they're considered pets and the soldiers will be sad when their pet war dogs are inevitably slaughtered.
Battle axes and warhammers are usually better than short swords and maces, respectively. Battle axes are usually better against unarmored targets; warhammers are strong against armored targets. Spears are more effective than either for killing large, unarmored things (like elephants, hydra, and dragons) because of their extremely high penetration depth, but they are generally not as good against goblins.
Of course, all this advice is useless if the goblins bring lasher squads. Run away from goblin lashers. You cannot fight them. We mean it. They're not called "Sith wargoblins" for nothing. Let the traps and marksdwarves deal with them.