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 部署不加项目名

 

相关文章:

  • 2021-10-16
  • 2021-06-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-05
  • 2021-12-05
猜你喜欢
  • 2021-07-07
  • 2021-04-19
  • 2022-12-23
  • 2021-09-27
  • 2022-01-07
  • 2022-01-23
  • 2021-09-28
相关资源
相似解决方案