?? flowcontrolservlet.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 + -