Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Servlet/JSP/JSF/JavaFX Script  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to postflat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:JSTL中报这个错误应该怎么解决,谢谢!!! [Re:小胖]
lisliefor





发贴: 287
于 2006-09-15 11:16 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
首先从这个地方确定是否有问题:JSTL配置,需要将c.tld、fmt.tld、fn.tld放到工程目录下,同时在web.xml中配置(注:我使用的IDE:Eclipse 3.2):
<!-- jstl taglib -->
  <jsp-config>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
      <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
    </taglib>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
      <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
    </taglib>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/fn</taglib-uri>
      <taglib-location>/WEB-INF/tld/fn.tld</taglib-location>
    </taglib>
  </jsp-config>

<taglib-uri>和<tablib-location>内容根据你在jsp页面使用<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>,和放置tld文件的位置来更改。
使用的时候,需要在相应JSP页面添加<taglib>标签。

然后,我们再看你的例子。首先,我调试过你的例子,没有报错!能够显示:

这里是一个简单的JSTL应用
Customers in the request:
guest11
guest22
guest33

现在的时间是:

时间显示不出来,I18N格式标签库,我没用过。不过那个now,你好像没有将它放置到任何隐藏对象中(page、request、session、application)。
而且这句也多余了:
<c:set var="customer" scope="session" value="${requestScope.customers}" />
如果你是为了试图使用<c:set>操作,那么,至少你在下面迭代中,items里的值,应该用${sessionScope.customers}。因为使用${customers},实际情况是这样的,编译器会依次从page、requset、session、application四个对象各自范畴内寻找。找到匹配, 则拿出来。
这样修改一些,结果可以看到,不知道是否合lz意思:
<body bgcolor="#FFFFFF">
<h3>这里是一个简单的JSTL应用</h3>
<%
  java.util.Date date = new java.util.Date();
  String now = date.toString();
  Collection customers = new ArrayList();
  customers.add(new String("guest11"));
  customers.add(new String("guest22"));
  customers.add(new String("guest33"));
  //设置customers为request的属性。
  request.setAttribute("customers", customers);
  request.setAttribute("now",now);
%>
<h4>Customers in the request:</h4>
<c:forEach var="customer" items="${customers}">
  <c:out value="${customer}" />
  <br>
</c:forEach>
<br>
现在的时间是:${now }
<br>

</body>




话题树型展开
人气 标题 作者 字数 发贴时间
2612 JSTL中报这个错误应该怎么解决,谢谢!!!(问题已解决) 小胖 1358 2006-09-14 12:00
2141 Re:JSTL中报这个错误应该怎么解决,谢谢!!! 小胖 80 2006-09-14 12:05
2105 Re:JSTL中报这个错误应该怎么解决,谢谢!!! floater 208 2006-09-14 23:37
2095 Re:JSTL中报这个错误应该怎么解决,谢谢!!! YuLimin 12 2006-09-14 20:38
2103 Re:JSTL中报这个错误应该怎么解决,谢谢!!! lisliefor 1815 2006-09-15 11:16
2130 Re:JSTL中报这个错误应该怎么解决,谢谢!!! 小胖 165 2006-09-15 21:23
2202 Re:JSTL中报这个错误应该怎么解决,谢谢!!! 小胖 102 2006-09-18 15:18

reply to postflat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923