📄 frontcontroller.java
字号:
package servlets;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import javax.xml.parsers.*;
import org.xml.sax.*;
import helps.*;
public class FrontController extends HttpServlet
{
private ServletConfig config;
public void init() throws ServletException
{
config=this.getServletConfig();
}
protected void processRequest(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
try
{
ServletContext scx=config.getServletContext();
String path = req.getPathInfo().substring(1);
Action action = ActionHelper.getAction(scx,path);
String nextView = action.process(scx,path,req,res);
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextView);
dispatcher.forward(req, res);
}
catch(ParserConfigurationException pce)
{
pce.printStackTrace();
}
catch(SAXException saxe)
{
saxe.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}
}
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
this.processRequest(req, res);
}
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
this.processRequest(req, res);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -