2-6自由编程报404错误了
package com.my.db; import java.util.HashMap; import java.util.Map; import com.my.students.Students; public class MyStudents { public static Map<Integer,Students> map=new HashMap<Integer,Students>(); static { map.put(1, new Students(110664125, "张学友", 97)); map.put(2, new Students(110664125, "刘德华", 96)); map.put(3, new Students(110664125, "吴彦祖", 95)); map.put(4, new Students(110664125, "郭富城", 94)); map.put(5, new Students(110664125, "黎明", 93)); map.put(6, new Students(110664125, "梁朝伟", 92)); } } package com.my.students; public class Students { private int ID; private String stuName; private int stuScore; public Students(int ID, String stuName, int stuScore) { super(); this.ID = ID; this.stuName = stuName; this.stuScore = stuScore; } public int ID() { return ID; } public void setID(int ID) { this.ID = ID; } public String getStuName() { return stuName; } public void setStuName(String stuName) { this.stuName = stuName; } public int getStuScore() { return stuScore; } public void setStuScore(int stuScore) { this.stuScore = stuScore; } @Override public String toString() { return "Students [ID=" + ID + ", stuName=" + stuName + ", stuScore=" + stuScore + "]"; } } <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" import="com.my.students.*,com.my.db.*,java.util.*"%> <!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=ISO-8859-1"> <title>Insert title here</title> </head> <body> <% Map<Integer,Students> map=MyStudents.map; //map.values().iterator(); /* Iterator<Map.Entry<Integer, Students>> it=map.entrySet().iterator(); */ Set<Map.Entry<Integer, Students>> set = map.entrySet(); Iterator<Map.Entry<Integer, Students>> it=set.iterator(); int i=1; if(it.hasNext()){ Students stu=it.next().getValue(); %> <p>第<%=i %>条:<%=stu %></p> <% i++; } %> </body> </html>
0
收起
正在回答
6回答
可以正常运行,没有报错呀,同学还是报500错误么?
摄影祖师爷
2018-08-02 17:57:19
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" import="com.my.students.*,com.my.db.*,java.util.*"%> <!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=ISO-8859-1"> <title>Insert title here</title> </head> <body> <% Map<Integer,Students> map=MyStudents.map; Set<Map.Entry<Integer, Students>> set = map.entrySet(); Iterator<Map.Entry<Integer, Students>> it=set.iterator(); int i=1; while(it.hasNext()){ Students stu=it.next().getValue(); %> <p>第<%=i %>条:<%=stu %></p> <% i++; } %> </body> </html>
从网页搭建入门Java Web2018版
- 参与学习 人
- 提交作业 1088 份
- 解答问题 10205 个
如果你有Java语言基础,又想以后从事Java Web开发,那么本路径是你的不二选择!本路径从网页搭建开始入手,通过大量案例来学习Java Web基础。定能助你完成Java Web小白的蜕变!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星