我在使用jstl编程的时候,使用了EL表达式,但是在使用的过程中,遇到了如下几个问题:(使用的环境是Eclipse)
1、纯粹的EL表达式解析不出来,但是当把EL表达式放在jstl的核心库的c:out标签中时,却能够显示出来。
如:1+1=${1+1}         //其显示结果为1+1=${1+1} 
如果写为:1+1=<c:out value="${1+1}">   //其显示结果为1+1=2
2、web.xml配置文件中如果我写成:<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">,在写下面的<taglib>标签是就会报错,如果将<taglib>标签放置在<jsp-config>标签中时,在要引用引入的标签时,能够只能提示,但是不能正常执行,其要报错。所以我只能够不要<jsp-config>标签,然后将web.xml中的<web-app>写成:<web-app id="WebApp_ID">,这样虽然引用标签能够正常执行,但是就会出现前面第一点的错误。
我是struts初学者,希望各位大虾能够给我帮助,不胜感激!!!!

解决方案 »

  1.   

    在jsp页面中有 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    吗?
      

  2.   

    有<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
    该引用的都引用了
      

  3.   

    <%page isELignoe="false" %>加个这个试试
      

  4.   

    <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">
    我用这个,貌似你那个写的不对,搜搜看看
      

  5.   

    <%@ page isELIgnored="false" %>
      

  6.   

    首先web-app_2_4.xsd 版本默认<%@ page isELIgnored="false" %>。
    而你给出的1+1= <c:out value="${1+1}"> 能够解析,这就说明不是EL不能解析的问题了。估计是你的web.xml配置有问题吧。没看明白你问题中的关于<taglib>那部分说的是什么意思。
      

  7.   

    jstl有标准包。一般会用2.5 那个空间Tomcate6.0版本+这样根本不用写一些无聊的配置。例如:<%@ page isELIgnored="false" %>。
      

  8.   

    就是说,如果把<taglib></taglib>标签写在<jsp-config></jsp-config>中后,在使用页面中使用
    <taglib>引入的标签时报错。
      

  9.   

    你用的 tomcat 5.5.x 版本,那么 web.xml 的 xsd 文件不能是 2_5 的!另外,你的那个 JSTL 也只能是 JSTL 1.1 版本的建议你到 tomcat 5.5.x 的目录中搜索 jstl.jar 文件,搜到后还有个 standard.jar 连同这两个文件复制到你工程的 WEB-INF/lib 中,web.xml 中也不需要加什么 taglib 标签(因为从 2.4 开始 WebAppClassLoader 会自动搜索 lib 中的 .tld 文件)。另外,如果 web.xml 是 2_5 的话,并不是把 2_5 改成 2_4 就行的!Servlet 2.4 规范的 web.xml 头是这样的:<web-app id="WebApp_ID" version="2.4"
          xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">而 2.5 规范是这样的:<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_2_5.xsd"
       version="2.5">2.4 的是 ns/j2ee,而 2.5 的是 ns/javaee
      

  10.   

    <?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">
    <jsp-config>
    <!--定义标签库-->
    <taglib>
    <!--确定标签库的URI-->
    <taglib-uri>/tags/test.tld</taglib-uri>
    <!-- 确定标签库定义文件的位置 -->
    <taglib-location>/WEB-INF/test.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/tags/test1.tld</taglib-uri>
    <taglib-location>/WEB-INF/test1.tld</taglib-location>
    </taglib>
    </jsp-config>
    你把配置发来看看,这我的,测试的
      

  11.   

    我用的jstl是1.0版本的。你说在Tomcat目录下面搜索jstl.jar包,没有啊,是安装目录吗?
    那里面没有jstl.jar包吧。
      

  12.   

    估计是这个 问题 我也碰到过,JSP头没加
      

  13.   

    11L
    如果web.xml中不加<taglib>标签,那么要在jsp页面中使用一些标签库的话,还需要使用
    <%@ taglib prefix="c" uri=""%>这个引用吗,如果要的话,uri的值该为什么呢?我现在将web.xml中
    的<taglib>标签去掉后,并且把jsp页面中也没有用<%@ taglib prefix="c" uri=""%>,在该页面中则不能使用jstl的核心库标签?
    该怎么弄啊 ?谢谢
      

  14.   

    jstl.jar放在lib下,你看下是不是你包冲突了
    你就不敢把配置发全点,让大家在这猜
    javaee1.4要加taglib吧
      

  15.   

    我的<web.xml>配置文件如下:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4"
          xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <jsp-config>
    <taglib>
    <taglib-uri>/WEB-INF/c.tld</taglib-uri>
    <taglib-location>/WEB-INF/c-1_0.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/WEB-INF/x.tld</taglib-uri>
    <taglib-location>/WEB-INF/x-1_0.tld</taglib-location>
    </taglib>
    </jsp-config></web-app>
    使用的jsp页面如下:
    <%@ page language="java" contentType="text/html; charset=gb2312"  pageEncoding="gb2312"%>
    <%@ page import="java.util.*,jstl_com.User" %>
    <%@ taglib prefix="c" uri="/WEB-INF/c.tld" %>
    <%@ taglib prefix="x" uri="/WEB-INF/x.tld" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>测试jstl</title>
    </head>
    <body>
    <h1>测试jstl</h1>
    <hr/>
    <li>显示普通字符串</li><br />
    el显示teststr=${requestScope.teststr}<br />
    jsp脚本显示teststr=<%= request.getAttribute("teststr")%><br />
    jstl核心库表示:teststr=<c:out value="${teststr}" /><br />
    配置文件写成那样,在执行该jsp页面时报错所<c:out>错误