feng

飘逸~~~~~life

JSTL的一点问题

今天在看JSTL一个测试程序

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ page contentType="text/html; charset=gb2312" language="java" %>
    <c:set var="userName" value="hellking"/>
    <c:set value="19" var="age"/>
    欢迎您,<c:out value="${userName}"/><hr>
   <c:forEach var="i" begin="1" end="5">
   <font size=${i}>${i}</font>
   <br>
   </c:forEach>

   <c:if test="${age<18}">
    对不起,你的年龄taida,不能访问这个网页◎!
   </c:if>
   <br>
   </body>
   </html>

的时候,发现放到JSTL的例子程序跟目录下就可以正确显示下面的结果

欢迎您,hellking


1
2
3
4
5

 但是在自己设置的子目录下就不能显示正确的结果,变成下面的样子


欢迎您,${userName}


${i}
${i}
${i}
${i}
${i}





找了很久发现是web.xml的配置问题,
原来子目录的配置是这样的,是从根目录下拷过来的

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app 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 web-app_2_4.xsd"
    version="2.4">

    <display-name>JSTL Examples</display-name>
    <description>
        Examples for the 'standard' taglib (JSTL)
    </description>

    <listener>
      <listener-class>org.apache.taglibs.standard.examples.startup.Init</listener-class>
    </listener>

    <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>index.html</welcome-file>
    </welcome-file-list>

</web-app>

后来发现把

    <listener>

      <listener-class>org.apache.taglibs.standard.examples.startup.Init</listener-class>
    </listener>

    <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>index.html</welcome-file>
    </welcome-file-list>
这些去掉就可以正常显示,我用的服务器是TOMCAT5。5  有谁知道原因的解释下啊??

posted on 2007-09-10 12:55 feng 阅读(183) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: