日期:2014-05-17  浏览次数:20786 次

SSH中JSP不支持EL表达式吗。。。很奇怪
是说怎么了,娶不到数据,光棍!!!!
我就随便测试下,结果

看下面JSP页面
 
HTML code

<%@ 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啊 


------解决方案--------------------
试试这样去获取
${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} 取得主机端的服务信息
------解决方案--------------------
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//在这里加一句
request.setAttribute("basePath ")
%>

------解决方案--------------------
el表达式是从application,session,request,page这些作用域内查找

加上<%request.setAttribute("basePath",basePath)%>即可

------解决方案--------------------
你没有把值放到作用域范围中当然是取不出来的。
作用域范转有四个。page范围、request范围、session范围、application范围
------解决方案--------------------
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" %>