写了这句话没有:<% page import="java.util.HashMap"%>
解决方案 »
- Tomcat免安装版 http://localhost:8080/不能显示页面
- java 怎么把动态数据固定格式的导入到world文档中,高手们帮帮忙了
- 请教关于return的用法
- java开发管理中,同一page下的各个java文件的日期管理问题!
- 关于hibernate中查询出来的对象为null的问题
- 关于List显示的一个小问题
- 控制台能输出数据,但为什么就是空指针错误,JSP页面不能显示啊
- javascript中函数指针问题?
- 在MyEclipse中使用自定义标签的一个错误
- 有谁能跟我讲讲J2SE,J2EE,J2ME,EJB,的用处
- 服务器访问服务器读xml文件,请高手请教
- 关于hibernate中左关联的问题?
HashMap months = new HashMap();
months.put("Jan","January");
months.put("Feb","February");
months.put("Mar","March");
request.setAttribute("months",months);
%>放到servlet里面试试呢
<bean:write name="element" property="key"/>
<bean:write name="element" property="value"/><br>
就是它出的问题,那个"key"和"value"是不是要在一个资源文件里定义啊?
<%@ page language="java" import="javax.servlet.http.Cookie,java.util.HashMap,java.util.Vector" pageEncoding="UTF-8"%><%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-template" prefix="template" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
<head>
<html:base />
<title>login.jsp</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">
</head>
<body>
<%
Vector animals = new Vector();
animals.addElement("dog");
animals.addElement("cat");
animals.addElement("bird");
request.setAttribute("Animals",animals);
%>
<logic:iterate id="element" name="Animals" indexId="index">
<bean:write name="index"/>..
<bean:write name="element"/><br>
</logic:iterate>
<%
HashMap h = new HashMap();
String vegetables[]={"01","02"};
String fruits[]={"03","04"};
String flowers[]={"rose","baihe","kangnaixin"};
h.put("vegetables",vegetables);
h.put("fruits",fruits);
h.put("flowers",flowers);
request.setAttribute("catalog",h);
%>
<logic:iterate id="element" indexId="ind" name="catalog">
<bean:write name="ind"/>
<bean:write name="element" property="key"/>
<logic:iterate id="elementValue" name="element" property="value" type="com.bean.element">
---<bean:write name="elementValue"/><br>
</logic:iterate>
</logic:iterate><p>
</body>
</html:html>
<%@ page language="java" import="javax.servlet.http.Cookie,java.util.HashMap,java.util.Vector" pageEncoding="UTF-8"%><%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-template" prefix="template" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
<head>
<html:base /><title>login.jsp</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">
</head><body>
<%
HashMap months = new HashMap();
months.put("Jan","January");
months.put("Feb","February");
months.put("Mar","March");
request.setAttribute("months",months);
%>
<logic:iterate id="element" indexId="ind" name="months">
<bean:write name="ind"/>
<bean:write name="element" property="key"/>
<bean:write name="element" property="value"/><br/>
</logic:iterate><p></body>
</html:html>这段代码是每问题的,有问题的话,看看你的部属是否正确。
<bean:write name="element" property="value"/>
这两个标签的name和property系统会直接知道具体是哪个"value"和"key"么?我用在写个java bean来定义一下么?
你的request.setAttribute("months",months);是往form里赋值吗?<logic:iterate id="element" indexId="ind" name="months">
<bean:write name="ind"/>
<bean:write name="element" property="key"/>
<bean:write name="element" property="value"/><br/>
</logic:iterate>
这个只能从form里取值的。
Vector animals = new Vector();
animals.addElement("dog");
animals.addElement("cat");
animals.addElement("bird");
request.setAttribute("Animals",animals);
%>
<logic:iterate id="element" name="Animals" indexId="index">
<bean:write name="index"/>..
<bean:write name="element"/><br>
</logic:iterate>
HashMap months = new HashMap();
months.put("Jan","January");
months.put("Feb","February");
months.put("Mar","March");
request.setAttribute("months",months);
%>
<logic:iterate id="element" indexId="ind" name="months">
<bean:write name="ind"/>
<bean:write name="element" property="key"/>
<bean:write name="element" property="value"/><br/>
</logic:iterate><p>
这段代码是不需要配置ation,formbean的。
你肯定是项目结构有问题,或者struts包和tld没倒入项目中。不要再去找代码的问题了,自己好好看看项目结构。
strmemo_H = "memo(" + Integer.toString(i)+ ")";
%>
<td>
<html:text name="eagle" property="<%=strmemo_H%>"value="<%=(String) mapModule.get("memo_" + Integer.toString(i))%>" >
</td>在form中
public static final String MEMO_KEY = "cmemo_";
public String getMemo(String key) {
if (tableMap.get(MEMO_KEY + key) == null) {
return "";
}
return (String) tableMap.get(MEMO_KEY + key);
} public void setMemo(String key, String value) {
this.tableMap.put(MEMO_KEY + key, value);
}