java web的简单编程题,纯jsp,题目见图片第四题,晚上六点前就要,做完请截图发给我
4个回答
推荐于2016-10-13
展开全部
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
List<Hashtable<String, String>> list = (ArrayList<Hashtable<String, String>>) request.getAttribute("list");
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>四题答案</title>
</head>
<body>
<table>
<thead>
<tr>
<th>特长</th>
<th>等级</th>
<th>喜爱指数</th>
</tr>
<%
for (Hashtable<String, String> ht : list) {
String skill = ht.get("skill");
String grade = ht.get("grade");
String degree = ht.get("degree");
%>
<tr>
<td><%=skill%></td>
<td><%=grade%></td>
<td><%=degree%></td>
</tr>
<%
}
%>
</thead>
<tbody>
</tbody>
</table>
</body>
</html>
import java.io.IOException;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class SkillList extends HttpServlet {
private static final long serialVersionUID = 1L;
private List<Hashtable<String, String>> list;
public SkillList() {
super();
}
public void destroy() {
super.destroy();
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("list", list);
getServletConfig().getServletContext().getRequestDispatcher("/1.jsp").forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("list", list);
getServletConfig().getServletContext().getRequestDispatcher("/1.jsp").forward(request, response);
}
public void init() throws ServletException {
if(null==list){
list = new ArrayList<Hashtable<String,String>>();
Hashtable<String,String> ht = new Hashtable<String,String>();
ht.put("skill", "开飞机");
ht.put("grade", "专业");
ht.put("degree", "0");
list.add(ht);
Hashtable<String,String> ht1 = new Hashtable<String,String>();
ht1.put("skill", "开坦克");
ht1.put("grade", "专业");
ht1.put("degree", "25");
list.add(ht1);
Hashtable<String,String> ht2 = new Hashtable<String,String>();
ht2.put("skill", "开潜艇");
ht2.put("grade", "专业");
ht2.put("degree", "50");
list.add(ht2);
}
}
}
<servlet>
<servlet-name>SkillList</servlet-name>
<servlet-class>SkillList</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SkillList</servlet-name>
<url-pattern>/servlet/SkillList</url-pattern>
</servlet-mapping>
展开全部
可以私信我 我可以帮到你
更多追问追答
追问
亲
有时间帮做一下好吗
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
30悬赏 晚上6点 洗洗睡吧亲
追问
题目很简单,要是会的话很快的,30是我全部身家了😨
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
java web还用eclipse 用myeclipse吧
追问
考试要求用eclipse😨
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询