zoukankan      html  css  js  c++  java
  • requestscope.contextpath和<%=request.getContextPath()%>有何区别?(待解答)

    问题1:requestscope.contextpath和<%=request.getContextPath()%>有何区别?

    问题2:${requestscope.contextpath}和${pageContext.request.contextPath}有何区别?

    需要访问一个AuthorityServlet服务器,该Servlet服务器在web.xml中的配置为:

    <servlet>
    <servlet-name>AuthorityServlet</servlet-name>
    <servlet-class>com.tt.javaweb.servlet.AuthorityServlet</servlet-class>
    </servlet>


    <servlet-mapping>
    <servlet-name>AuthorityServlet</servlet-name>
    <url-pattern>/authorityServlet</url-pattern>
    </servlet-mapping>

    很明显,url-pattern里的/代表当前WEB应用的名称:20161025,即需要以/20161025/authorityServlet访问AuthorityServlet服务器。

    获取当前当前WEB应用的名称:request.getContextPath()=/20161025,(其中/代表当前站点的根目录:http://localhost:8080)

    访问方式:<%= request.getContextPath() %>/authorityServlet等价于/20161025/authorityServlet,通过此方式可以访问AuthorityServlet服务器

    现在问题在于:${requestScope.contextPath }/authorityServlet为什么无法访问AuthorityServlet服务器?

    难道${requestScope.contextPath }和<%= request.getContextPath() %>不相等吗?

    而${requestScope.contextPath }authorityServlet却可以访问到AuthorityServlet服务器?

  • 相关阅读:
    求出123456 8910,数字,显示出来
    Django之Model操作
    AJAX全套
    Python之路【第十六篇】:Django【基础篇】
    Q2Day81
    Django第二重点(thml与django连接)
    react
    es6 和 python 语法比较
    微信
    py库: GUI(tkinter)
  • 原文地址:https://www.cnblogs.com/TTTTT/p/6002115.html
Copyright © 2011-2022 走看看