3.定义控制类loginAction.Java和commandClass-->LoginInfo.java <---------------------LoginAction----------------------------> public class LoginAction extends SimpleFormController {
Document doc = DocumentHelper.createDocument(); Element root = doc.addElement(rootName); doc.setRootElement(root); List loginInfos = (List) model.get("loginInfos"); for (Iterator it = loginInfos.iterator(); it.hasNext();) { LoginInfo info = (LoginInfo) it.next(); Element a = root.addElement("loginInfo"); a.addElement("username").addText(info.getUsername()); a.addElement("password").addText(info.getPassword());
} response.setContentType("text/xml"); return new DOMWriter().write(doc); }