抱歉,我没有实际的代码,但我会尝试解释:
我有一个映射到以下内容的 servlet:
/admin/*
因此,这将转到一个 servlet:
public class AdminController extends MainController {
public void doPost(HttpServletRequest request, HttpServletResponse response) {
// Do stuf here
}
}
这是主控制器:
public class MainController extends HttpServlet {
@Override
public void service(ServletRequest request, ServletResponse response) {
String requesturi = ((HttpServletRequest)request).getRequestURI();
reqlist = Arrays.asList(requesturi.substring(requesturi.indexOf(Util.rootPath) + Util.rootPath.length()).split("/"));
reqlist = reqlist.subList(1, reqlist.size());
doPost((HttpServletRequest)request, (HttpServletResponse)response);
}
所以,请求被传递给 AdminController,没问题,但后来我意识到:
servlet 被调用了两次!. 这给我带来了很多错误..
有人对此有所了解吗?是因为我使用了某种传承?感谢你所做的一切!