qq_38081432 2019-06-02 19:17 采纳率: 100%
浏览 1164
已采纳

jsp{pageContext.request.contextPath}无法获取

图片说明

图片说明

        <div>
            <input class="ui-dialog-submit"  type="submit" value="登录">
        </div>
          <div align="center"><font color="red">${error}</font></div>
        <div class="ui-dialog-l40">
            <a href="${pageContext.request.contentType}/register.jsp">立即注册</a>
        </div>


    跳出404是因为解析不出el表达式吗?
    web.xml配置
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">

在jsp的指令加上这句话isELIgnored="false",也是跳404

  • 写回答

4条回答 默认 最新

  • qq_35151346 2019-06-02 19:55
    关注

    j2ee Api文档:
    javax.servlet
    Interface ServletRequest
    getContentType()
    Returns the MIME type of the body of the request, or null if the type is not known.
    javax.servlet.http
    Interface HttpServletRequest
    getContextPath()
    Returns the portion of the request URI that indicates the context of the request.

    首先              
                    pageContext.request获取的对象是HttpServletRequest的实现类还是ServletRequest的实现类,这点你没搞懂。其次。看api文档。
                    意思是什么。
                     getContentType()返回request的一个mime类型。如果不知道,则为空。
                    getContextPath() 返回一个请求的URI。你这里要的肯定是路径吧,不是格式吧。
                    ${pageContext.request.contentType}换成${pageContext.request.contextPath}。不知道你xml中配置servlet没。其他的错我不知道,但这一步是错的
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 虚心请教几个问题,小生先有礼了
  • ¥30 截图中的mathematics程序转换成matlab