⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loginaction.java~21~

📁 xml 作为数据库
💻 JAVA~21~
字号:
package struts.form;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.Action;
import DAO.StudentDTO;
import DAO.XMLParser;
import java.util.*;

public class LoginAction extends Action {
    public ActionForward execute(ActionMapping actionMapping,
                                 ActionForm actionForm,
                                 HttpServletRequest request,
                                 HttpServletResponse response) {

        List array = new ArrayList();
        StudentDTO stu = new StudentDTO();
        XMLParser parser = XMLParser.newInstance();
        array = parser.getAllStudent();//获取所有友好信息
        request.setAttribute("success","成功获取");
        request.setAttribute("array",array);

        System.out.println("路径为:"+request.getServletPath());

//        String realPath = getServletContext().getRealPath("/");
//        System.out.println(getServletContext().getInitParameter("filename") +
//                           "<<<<<");
//
//        String filename = getInitParameter("xmlfile");
//        XMLParse.path = realPath + filename;
//        XMLParse parser = XMLParse.getInstance();

        Iterator it = array.listIterator();
        while(it.hasNext())
        {
            stu = (StudentDTO)it.next();
            System.out.println(stu.getName());
        }
        return actionMapping.findForward("login");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -