刚开始学习Struts,在的Struts常用标签库时,有一个测试<bean:cookie>的例子,在MyEclipse里老是报错,不过在页面里却能正常运行,不知道是怎么回事,求高手解答。 所报的错误: <bean:cookie>处:The TagExtraInfo class for "bean:cookie" (org.apache.struts.taglib.bean.CookieTei) could not be instantiated mycookie处:mycookie cannot be resolved 为什么不能被实例化啊?
- <%@ page language="java" pageEncoding="GB18030"%>
- <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
- <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
- <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
- <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html:html lang="true">
- <head>
- <html:base />
- <title>bean_define.jsp</title>
- </head>
- <body>
- <[b][u]bean:cookie[/u][/b] name="username" id="mycookie" value="MLDN"/>
- <%
- [b][u] mycookie[/u][/b].setMaxAge(3000);
- response.addCookie(mycookie);
- %>
- <% // 取得全部Cookie
- Cookie cookies[] = request.getCookies();
- for(int x = 0; x < cookies.length; x++) {
- %>
- <h2><%=cookies[x].getName()%> --> <%=cookies[x].getValue()%></h2>
- <%
- }
- %>
- </body>
- </html:html>
复制代码
|