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

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没。其他的错我不知道,但这一步是错的
<%=request.getContextPath()%>和${pageContext.request.contextPath}获取的结果都是项目名(上下文),而不是我们想要的那个结果,可是如果我们想要获取项目的绝对路径和端口号我们有什么办法呢

  

<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

https://www.cnblogs.com/zhangminghui/p/4122821.html

js 中 window.location.origin

1、 第一种、在JSP页面的头部信息 添加 一个配置 isELIgnored=“false”,即
<%@ page contentType=“text/html;charset=UTF-8” language=“java” isELIgnored=“false”%>
但是这个配置是局部的配置,只在这个JSP页面生效。

2、第二种、因为web.xml文件中的标头版本不对,改为2.4版本及其以上也可以解决问题,这个是全局,即在整个项目都适用。

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

version="3.0">

还有就是在2.3版本及其以前的版本 isELIgnored=“true” 这个默认的是true,并且,貌似2.5的版本也是为true来