springmvc action访问路径不带项目名

action url不带项目名导致无法访问action

 jsp action 添加项目名

  在JSP页面获取当前项目名称的方法:

  方法1: <%= this.getServletContext().getContextPath() %>

或者使用request

  1.request.getSchema();可以返回当前页面所使用的协议,就是"http"

  2.request.getServerName();返回当前页面所在服务器的名字,就是上面例子中的"localhost"

  3.request.getServerPort();返回当前页面所在服务器的端口号,就是上面例子中的"8080"

  4.request.getContextPath();返回当前页面所在的应用的名字

  方法2: 使用EL表达式

  ${pageContext.request.contextPath}
 tomcat 部署不加项目名

原文地址:https://www.cnblogs.com/woftlcj/p/10278618.html