是说怎么了,娶不到数据,光棍!!!!
我就随便测试下,结果看下面JSP页面
 
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP '11.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->  </head>
  
  <body>
    This is my JSP page. ${path}<br/>${basePath }
    <c:out value="${basePath}"></c:out><br/>
    <%=basePath %>
    <br/>是:${basePath }
  </body>
</html>结果页面显示This is my JSP page. http://localhost:8080/shop2/ 
是:
----------------------
${path}<br/>${basePath }的值没有。。----------------------
何解  以前都好好的 
JSP2.0啊 

解决方案 »

  1.   

    servlet版本呢,web.xml贴出来看看
      

  2.   

    试试这样去获取
         ${pageContext.request.queryString}         取得请求的参数字符串
         ${pageContext.request.requestURL}         取得请求的URL,但不包括请求之参数字符串
         ${pageContext.request.contextPath}         服务的web application 的名称
         ${pageContext.request.method}           取得HTTP 的方法(GET、POST)
         ${pageContext.request.protocol}         取得使用的协议(HTTP/1.1、HTTP/1.0)
         ${pageContext.request.remoteUser}         取得用户名称
         ${pageContext.request.remoteAddr }         取得用户的IP 地址
         ${pageContext.session.new}             判断session 是否为新的
         ${pageContext.session.id}               取得session 的ID
         ${pageContext.servletContext.serverInfo}   取得主机端的服务信息
      

  3.   

    tomcat5.5默认不解析EL,不知道你用的什么容器如果是5.5,那么修改web.xml中声明部分的schema版本为2.4或者在使用了EL表达式的所有JSP页面的中加入page指令添加 isELIgnored="false",
           形如:<%@ page    isELIgnored="false"  %>
      

  4.   

    如果web.xml中版本是2.3的话,
    改成<%@ taglib uri="http://java.sun.com/jsp/core" prefix="c"%>试试看
      

  5.   

    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    //在这里加一句
    request.setAttribute("basePath ")
    %>
      

  6.   

    web.xml
    -----------------------<?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" 
    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_2_5.xsd">

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param> <!-- org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter -->
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter> <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
    </filter-mapping>

    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.jsp</url-pattern>
    </filter-mapping>

      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      
      <!-- 监听器 -->
      <listener>
      <listener-class>
      org.springframework.web.context.ContextLoaderListener
      </listener-class>
      </listener>
      
    </web-app>
      

  7.   

    这样就是通过request取了  不知道行不行  试试   EL也会通过不同作用域去取的  先试试  QQQ
      

  8.   

    el表达式是从application,session,request,page这些作用域内查找加上<%request.setAttribute("basePath",basePath)%>即可
      

  9.   

    可以娶到了  貌似想到了一个问题 不知道怎么说了  是关于JSP中变量和EL表达式的  哎 不记得了 。纠结
      

  10.   

    你没有把值放到作用域范围中当然是取不出来的。
    作用域范转有四个。page范围、request范围、session范围、application范围
      

  11.   

    <%@ page isELIgnored="false" %>
      

  12.   

    应该加个头文件就可以了吧:<%@ page isELIgnored="false" %> 
      

  13.   

    不是这个问题 这样只是设置你JSP忽略EL与否EL不能访问局部变量,只能访问作用域中的属性
      

  14.   

    jar包看看导了没有
    还有把<%@ taglib uri="http://java.sun.com/jsp/core" prefix="c"%>这句话放在<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>这句话的下面,不要放在,<% String path....%>的后面
    自己做个简单的例子<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
       
      </head>
      
      <body>
       <%
        List list=new ArrayList();
        list.add(1);
        list.add(2);
        list.add(3);
        request.setAttribute("list",list);
        %>
        <c:forEach items="${list}" var="p">${p}</c:forEach>
      </body>
    </html>看看能不能打印
      

  15.   

    这个和顺序无关系,我觉得
    你这里把数据放在request作用域里面当然是可以读取的了
    我刚才basepath变量是在本地范围的,EL中直接这样取是取不到的,必须在他支持的
    四个作用域(pageScope, requestScope, sessionScope和applicationScope)
    中取
    嗯 
    就酱紫
    谢谢关注
      

  16.   

    写一头文件<%@ page isELIgnored="false" %>
    估计就ok了