httpservletrequest对象详解
找ctx代表什么。假如:pageContext.setAttribute("ctx", application.getContextPath());从上面的解说可以知道System.out.println(request.getContextPath())得出的是/news。故完整路径为:/news/admin/category/create.do。至于参数则根据实际研究。 可看到上路径为.do结尾。Spring MVC与Struts从原理上很相似(都是基于MVC架构),都有一个控制页面请求的Servlet,处理完后跳转页面。spring会自动扫描找到该路径对应的controller,如下图所示: 当前对应的路径为CategoryController类下的showCreate方法 String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 输出: path:/E_WuLiu basePath:http://localhost:8080/E_WuLiu/ getContextPath():得到当前应用的根目录 getScheme()