HTTP Status 404 – 未找到
http://localhost:8080/ajax/channel?level=1
Type Status Report
消息 /ajax/channel
描述 源服务器未能找到目标资源的表示或者是不愿公开一个已经存在的资源表示。
Apache Tomcat/8.5.53
package com.imooc.ajax;
public class Channel {
private String code;
private String name;
public Channel() {
}
public Channel(String code, String name) {
super();
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.imooc.ajax;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
/**
* Servlet implementation class ChannelServlet
*/
@WebServlet("/channel")
public class ChannelServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public ChannelServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String level = request.getParameter("level");
String parent = request.getParameter("parent");
List chlist = new ArrayList();
if(level.equals(1)) {
chlist.add(new Channel("ai","前沿/区块链/人工智能"));
chlist.add(new Channel("web","前端/小程序/JS"));
}else if(level.equals(2)) {
if(parent.equals("ai")) {
chlist.add(new Channel("micro" , "微服务"));
chlist.add(new Channel("blockchain" , "区块链"));
chlist.add(new Channel("other" , "..."));
}else if(parent.equals("web")) {
chlist.add(new Channel("html" , "HTML"));
chlist.add(new Channel("css" , "CSS"));
chlist.add(new Channel("other" , "。。。"));
}
String json = JSON.toJSONString(chlist);
response.setContentType("text/html;charset=utf-8");
response.getWriter().println(json);
}
}
}
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 676 份
- 解答问题 9666 个
本阶段将从前端网页搭建入手,到Java Web基础,前后端结合助你完成Java Web小白的蜕变!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星