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

📄 flowcontrolservlet.java

📁 系统包含求职用户和系统管理员两个角色
💻 JAVA
字号:
/*
 * 创建日期 2005-8-29
 *
 * TODO 要更改此生成的文件的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
package com.publish.jxc.charpter9;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;

/**
 * @author Administrator
 *
 * TODO 要更改此生成的类型注释的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
public class FlowControlServlet extends HttpServlet {
    private ActionXMLAction actions = null;
    
    private BaseXMLAction baseXMLAction = null;
    
    private Command command = null;
    
    String webRealPath = null; 
    
    protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1)
            throws ServletException, IOException {
        // TODO 自动生成方法存根
        doPost(arg0, arg1);
    }
    
    protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1)
            throws ServletException, IOException {
        // TODO 自动生成方法存根
        try
        {
	        String actionName = arg0.getParameter("actionName");
	        if (actions==null || actions.size()<=0 ||
	                actionName==null || actionName.equals(""))
	        {
	            Utility.forwardToErrorPage(arg0, arg1);
	        }
	        ActionXMLModel action = actions.getActionByName(actionName);
	        if (action==null || action.getUrl()==null || action.getUrl().equals(""))
	        {
	            Utility.forwardToErrorPage(arg0, arg1);
	        }
	        baseXMLAction = ActionFactory.newXMLAction(action.getActionmodel());
	        command = ActionFactory.newCommand(action.getCommandmodel());
	        command.doActionEntrance(arg0, arg1, baseXMLAction, webRealPath + action.getXmlfile());
//	        command.doAction(baseXMLAction, webRealPath + action.getXmlfile(), strIndex);
//	        HttpSession session = arg0.getSession(true);
//	        session.setAttribute("showList", baseXMLAction.getArray());
	        Utility.forwardToSpecialPage(arg0, arg1, action.getUrl());
        }
        catch(Exception e)
        {
            e.printStackTrace();
            arg1.setContentType("text/html");
            arg1.setCharacterEncoding("gb2312");
            PrintWriter out = arg1.getWriter();
            out.print(Utility.outPrintPage("Servlet应用程序发生错误!"));
        }
    }
    
    public void service(ServletRequest arg0, ServletResponse arg1)
            throws ServletException, IOException {
        // TODO 自动生成方法存根
        super.service(arg0, arg1);
    }
    
    public void init(ServletConfig arg0) throws ServletException {
        // TODO 自动生成方法存根
        super.init(arg0);
        initailizeActionParser(arg0);
    }
    
    private void initailizeActionParser(ServletConfig config)
    {
        ServletContext ctxt = config.getServletContext();
        webRealPath = ctxt.getRealPath("/");
        String fileName = webRealPath + Utility.Actions_XML_File;
        actions = new ActionXMLAction();
        actions.readXMLFile(fileName);
    }
}

⌨️ 快捷键说明

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