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

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条)

报告相同问题?