📄 dispatcherservlet.java
字号:
package com.hongsoft.res.dispatcher;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.hongsoft.res.util.CommandMap;
/**
* <p>
* Description: 分发器,系统唯一的Servlet入口,Dispatcher自动根据CommandName 分发到相关的Command
* </p>
*/
public class DispatcherServlet extends HttpServlet {
private static final long serialVersionUID = -1586474518907595440L;
// Initialize global variables
public void init() throws ServletException {
}
// Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
CommandRequest req = new CommandRequest(request);
CommandResponse res = new CommandResponse(response);
String cmdName = req.getCommandName();
try {
BaseCommand cmd = CommandMap.getCommand(cmdName);
cmd.setRequest(req);
cmd.setResponse(res);
cmd.command();
} catch (Exception e) {
e.printStackTrace();
}
}
// Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
// Clean up resources
public void destroy() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -