request 取得contextpath 和 config取得contextpath有什么区别
程序代码:
public ActionMapping getActionMapping(HttpServletRequest request){ String requestURI = request.getRequestURI(); String str=request.getContextPath(); String contextPath = config.getServletContext().getContextPath(); System.out.println(str); System.out.println(contextPath); String actionName = requestURI.substring(contextPath.length()+1, requestURI.lastIndexOf(".")); ActionMapping actionMapping = ActionManager.mappings.get(actionName); return actionMapping; }